Disable Landing Page Tracking

Your software
My Mautic version is: 2.16.2
My PHP version is: 7.3.17

Your problem
My problem is: As of European Law I need to request consent for cookies before them being set. With a javascript code I was able to disallow mautic cookies after they are set. But on first page load Mautic loads cookies via mtc.js which I like to prevent until the visitor has given consent to set these cookies.

The following line seems to be injected into the pages automatically:

I did not found anything in the template files which is used.

This is about the Mautic internal Landing Pages not any external website where the Mautic Tracking Code must be manually inserted.

Where do I disable the automatic tracking for Mautic Landing Pages?

These errors are showing in the log: No.

Steps I have tried to fix the problem:
Searched numerous files and the internet, but did not found any hint how to disable Mautic landing page tracking.

Every help is welcome. Thanks.

Hi there,

Such blocking is done by Consent Manager tools (many in the Mautic world use https://tarteaucitron.io/, but there are plenty others, free as well as commercial)

To embed it, simply place the tool’s JavaScript snippet in a “code mode” block in the Landing Page builder.


Subscribe to the Mautic Podcast at www.Mauticast.com - and let me know what topics or interviews you would like to hear!
(German version at www.Mauticast.de)

1 Like

Hi ekke,

thanks for your reply. I’m not using Code Mode for the Landing Pages as I do not want to fiddle with the code all the time.

I just copied the whole html markup in a test landing page in Code Mode. Same result, cookies are set without prior consent on first page load.

The following lines are injected before the </head> tag:

<script src="https://www.example.com/go/mtc.js" async data-source="mautic"></script>
<script data-source="mautic">
disable_notification = true;

They are not part of the code that I just added in the Code Mode for the landing page.

Edit: Tried the Tarteaucitron Cookie Consent Script either, with the same result. The above lines still get injected.

Where could I disable that these lines are added automatically?

Thanks a lot!


Sorry Stephan, I really meant a “code mode” block in the Builder. Please give that try!

Hi ekke,

tried the code mode block in the builder now. That is not working at all. The Cookie-Consent Script is not even executed.

I got the tarteaucitron.js working though it deletes the tracking cookies when the visitor denies consent. To do so I took the page html from the database and added the necessary code before entering it back to the database. As soon as everything works as intended, I’ll probably adjust the theme files to have these things included by default.

However, the tracking cookies are still set prior consent. Thus the code lines mentioned earlier still get injected. If there is a way to prevent this, it would solve the whole issue.

Thanks for your help so far.


Here is the process of what I wanted:

  1. delete all Cookies set by Mautic prior Visitor Consent when a Mautic Landing Page is visited.
  2. Set Cookies as per Visitor Consent (by using tarteaucitron.js consent tool)

The Solution:

  1. Create a Cookie called “priorconsent” with value “NoConsentYet” (using javascript)
  2. Check for the above cookie and state, if exits delete all Mautic Cookies and the cookie created under 1)
  3. Set Cookies using tarteaucitron.js and refresh page on every Cookie change.

To 3) to work as I intended I needed to change:
tarteaucitron.js line 31 “reloadThePage”: false, to “reloadThePage”: true,
and needed to add window.location.reload(); to the onclick event for the “OK, accept all” button (lines 314 and 381).

That’s it. Now it works as I like it to work.

To make all this work for all Landing Pages, I’ll going to update the Landing Page Template files according to include the solution above.



Here is an Update to my post from May 2020.

I adjusted the base.html.twig files of a Landing Page Theme I like to use, thus it includes all the links and javascripts to make the Cookie Consent work properly.

What I discovered is, that when I load the theme landing page, the body tag onload=“myfunction()” in <body onload="myfunction()"> is removed. Thus I tried a script in the head section with window.onload = myfunction() like <script type="text/javascript"> window.onload = myfunction(); </script>. No surprise, this was removed by Mautic on page load either.

Does anyone has an idea where and how Mautic is removing javascript or html tags on the fly?

BTW, if I add the body onload is not removed by Mautic, if I add it to the related page in the database. But I don’t like to go into the DB all the time.

I’m running the newest version of Mautic 3.2.4 on my own Server.

Every help is appreciated.

Oh, I wish everyone a marvelous year 2021 :wink: