How to remove the tracking script at the end of a Cloud Page

Marketing Cloud injects tracking collect codes at the bottom of Cloud Pages - there has to be a simple way to remove it.


You probably landed at this article because you saw this piece of JavaScript that looks like it's for tracking page visits.

That's exactly what it is - the script will record visits to your Cloud Page for reporting purposes when it comes round to finding out who's been access your pages, but there's no way to physcially remove it via the Cloud Page settings.

There is the "Web & Mobile Analytics" option at the top of the editor but I found that disabling this didn't remove the actual JavaScript itself.

Cloud Page - Web & Mobile Analytics 


After some playing around I found that the Code Resources component of the Cloud Pages will allow you to render your page without this script on - the only problem here is that there is not HTML option for a code resource.

What I did was create a new Code Resource by choosing the JSON type and paste my HTML in. What you'll notice after publishing is that the HTML would only show as plain text.

The final part is to change the Content Type of the page for the browser to render the page as HTML. Simply add the following Server Side Javscript to the very top of your page.

<script runat="server" type="text/javascript">
Platform.Load("Core", "1.1.5");
Platform.Response.SetResponseHeader("Content-Type", "text/html; charset=UTF-8");

You'll be able to continue using the Cloud Page without the tracking script that Marketing Cloud injects in to your HTML.

Sandeep Bansal
Salesforce Marketing Cloud Technical Architect
Follow me on LinkedIn


Powered by