Mautic Community Forums

Mautic Form - Google Tag Manager

Hi,

I am trying to insert a automatic form in a gtm tag but it´s not working. Nothing appear.

Does anyone had any idea why is this happening?

thanks

Hi,
I am trying to insert a automatic form in a gtm tag but it´s not working. Nothing appear.
Does anyone had any idea why is this happening?
thanks

No one???

I have no idea what is a gtm tag and how did you insert a form in it. So I’d like to help, but you’d have to describe your steps in more detail.

Here’s how I did it:

[h]Step 1:[/h]
I created a new custom javascript variable called Mautic Trackin Pixel Url with the following javascript. Make sure that you change that URL to yours and double check that http/https.

function mauticPixel() { var title = document.title; var url = window.location.href; var userLang = navigator.language || navigator.userLanguage; var trackingPixel = "https://yoururl.com/mtracking.gif?url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title)+ "&language=" + encodeURIComponent(userLang); return trackingPixel; }

[h]Step 2:[/h]
Create a new Custom Image Tag.

For the Image URL use:

{{Mautic Trackin Pixel Url}}&{{Referrer}}

I enable cache busting but you can configure the rest of the options the way you need and BAM! You have some advanced tracking using Google tag manager.

This is great! thanks

You’re welcome, let me know if it gives you any problems.

Awesome! Thank You.

I made mine slightly differently (I suspect Google’s tag manager has changed slightly since your post)

I created a new “Custom HTML” tag with the mtc.js tracking javascript code in, and set the Triggering to All Pages

this script also passes the url’s query string items along to Mautic.


  	var urlParams;
	(window.onpopstate = function () {
    	var match,
        	pl     = /+/g,  // Regex for replacing addition symbol with a space
        	search = /([^&=]+)=?([^&]*)/g,
        	decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
        	query  = window.location.search.substring(1);

    	urlParams = {};
    	while (match = search.exec(query))
    	   urlParams[decode(match[1])] = decode(match[2]);
	})();
	

    (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','https://yoururl.com/mtc.js','mt');
	mt('send', 'pageview',  urlParams);

How to integrate mautic form code ( {form=3} ) in google tag manager?