# Mautic Form - Google Tag Manager

**URL:** https://forum.mautic.org/t/mautic-form-google-tag-manager/2643
**Category:** Product Support
**Created:** [October 28, 2015, 2:02pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643 "2015-10-28T14:02:19Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Filipe](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@Filipe](https://forum.mautic.org/u/Filipe)
#### Post date: [October 28, 2015, 2:02pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/1 "2015-10-28T14:02:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Filipe](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@Filipe](https://forum.mautic.org/u/Filipe)
#### Post date: [October 28, 2015, 2:02pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/2 "2015-10-28T14:02:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Filipe](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@Filipe](https://forum.mautic.org/u/Filipe)
#### Post date: [November 9, 2015, 5:12pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/3 "2015-11-09T17:12:15Z")

</div>

No one???

---

<div class="post-metadata">

### Author: ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)
#### Post date: [November 11, 2015, 12:41pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/4 "2015-11-11T12:41:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ardit](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@ardit](https://forum.mautic.org/u/ardit)
#### Post date: [November 17, 2015, 9:52pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/5 "2015-11-17T21:52:52Z")

</div>

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) + "&amp;title=" + encodeURIComponent(title)+ "&amp;language=" + encodeURIComponent(userLang);
    return trackingPixel;
}`

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

For the Image URL use:

```auto
{{Mautic Trackin Pixel Url}}&amp;{{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.

---

<div class="post-metadata">

### Author: ![mroberto](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mroberto](https://forum.mautic.org/u/mroberto)
#### Post date: [November 18, 2015, 2:28am UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/6 "2015-11-18T02:28:53Z")

</div>

This is great! thanks

---

<div class="post-metadata">

### Author: ![ardit](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@ardit](https://forum.mautic.org/u/ardit)
#### Post date: [November 18, 2015, 6:15am UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/7 "2015-11-18T06:15:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hansakoch](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hansakoch](https://forum.mautic.org/u/hansakoch)
#### Post date: [November 17, 2016, 7:18pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/8 "2016-11-17T19:18:22Z")

</div>

Awesome! Thank You.

---

<div class="post-metadata">

### Author: ![OA\_Andrew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oa_andrew/32/497_2.png) [@OA\_Andrew](https://forum.mautic.org/u/OA_Andrew)
#### Post date: [April 3, 2017, 6:02am UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/9 "2017-04-03T06:02:48Z")

</div>

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.

```auto

  	var urlParams;
	(window.onpopstate = function () {
    	var match,
        	pl = /+/g, // Regex for replacing addition symbol with a space
        	search = /([^&amp;=]+)=?([^&amp;]*)/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);

```

---

<div class="post-metadata">

### Author: ![frontend1](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@frontend1](https://forum.mautic.org/u/frontend1)
#### Post date: [May 14, 2018, 2:25am UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/10 "2018-05-14T02:25:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)
#### Post date: [February 2, 2020, 10:57pm UTC](https://forum.mautic.org/t/mautic-form-google-tag-manager/2643/11 "2020-02-02T22:57:03Z")

</div>


