1

I have created a campaign form in Mautic and used the manual copy feature to integrate it into my HTML landing page (this is a landing page I have made in HTML. It is not a Mautic landing page).

In Mautic, users are saved as a "contact". The contact has a field called "tags".

I would like to make use of the Mautic Tracking Javascript so I can send a value to this tag field from my HTML landing page.

Here is my code:

< script >
    (function(w, d, t, u, n, a, m) {
        w['MauticTrackingObject'] = n;
        w[n] = w[n] || function() {
                (w[n].q = w[n].q || []).push(arguments)
            }, a = d.createElement(t),
            m = d.getElementsByTagName(t)[0];
        a.async = 1;
        a.src = u;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'http://newsletter.smile.ws/mtc.js', 'mt');
mt('send', 'pageview', {
    'tags': 'sunshine-book'
});
< /script>

To test it out, I submitted a test contact on my HTML landing page.

When I log-into Mautic and go to the contact page for the contact, the tag field is blank:

Contact field

However, the tag does appear as an option in the tag menu:

tagmenu

How can I make it so the tag field is automatically filled with the tag?

The user renzof of the Mautic forum tested my code and it worked for him, but it didn’t work for me. I think I'm doing something wrong, but I can't figure it. Any ideas? Thanks!

big_smile
  • 1,487
  • 4
  • 26
  • 59

2 Answers2

2

The issue is the use of Http. The landing page uses https, but the code was using http (the s is missing), which is why it doesn't work. I updated all my code to use https and it worked.

big_smile
  • 1,487
  • 4
  • 26
  • 59
1

there is actually nothing wrong with your code, I tested it and the only problem was browser blocking the request due to cors origin, other than that it worked fine.

But I have a hunch in case it doesn't work, i noticed the tags is actually plural and in mautic contact form it taken as array, so if cross domain issue isn't there at your end, can you try tags[] instead tags. However i think normal way should have worked.

Mayank Tiwari
  • 919
  • 1
  • 6
  • 13