DocsFor Websites
Install

Installing Trackingplan on Your Websites

Install Trackingplan on your website with Google Tag Manager or a snippet in your pages, then see how it works, its advanced options and Content Security Policies.

Install Trackingplan on your website with Google Tag Manager or a snippet in your pages. Your install page, https://app.trackingplan.com/plans/YOUR_TP_ID/install, gives you the code for each method, ready to copy.

In this section:

Most teams install Trackingplan with Google Tag Manager or by copying the snippet onto your website.

The install page

The install page has one tab per method. This page covers GTM and Snippet. Segment gives a webhook URL (see Webhooks), and iOS and Android point you to support for the app SDKs (see For Apps).

Each tab has Copy Snippet and Share instructions, so you can send the code to whoever installs it. Further down, Checking your implementation status shows Data connected once Trackingplan receives your data.

The install page, CDN tab
The install page, CDN tab

Using Google Tag Manager

If you use Google Tag Manager, you can install Trackingplan without touching your site’s code. Here is how:

  1. Log in to Google Tag Manager.
  2. Create a New tag inside the container connected to your website.
  3. Hover over the Tag Configuration box and click on the gray pencil icon.
  4. Choose the tag type: select Custom HTML Tag.
  5. Paste your Trackingplan snippet into the HTML text box. You can always get your snippet from https://app.trackingplan.com/plans/”your TP_ID”/install
  6. Set up the tag’s advanced settings. Click Advanced Settings and set Tag firing Priority to 1000 and Tag Firing Options to Once per page so Trackingplan can see events that fire once the page has loaded.
  7. In the Triggering box, click the gray pencil icon to choose a trigger. For the best results, select Initialization - All Pages.
  8. Once saved, Trackingplan loads on every page where the Google Tag Manager container script is installed. Remember to Submit your changes.

All done. Now check that data collection is working, so you know Trackingplan is monitoring and documenting all the customer data you use for analytics, marketing and sales.

GTM Tip: Track GTM Version and ID as a Custom Dimension (Optional)

You can add any data tagged in your GTM to the Trackingplan script as tags, so Trackingplan has more context when it detects problems.

To attribute warnings to configuration changes later, show those changes as releases and see them in root-cause analysis (RCA), we recommend sending GTM’s Container Version as tags.

The container version label is standard, so you can add it just as in the example below.

tags: {
...
"gtm_container_version": "{{Container Version}}"
...
}

If you use more than one GTM container, you can also add the Container ID as a tag. Configure it in GTM first, as shown in the image below.

Add Trackingplan’s Snippet to Your Site

You can also install Trackingplan by adding our snippet to your site. Here is how:

Note: If you don't use a content management system (CMS) like Webflow or WordPress, we recommend asking a developer to add the snippet to your pages. If it is installed incorrectly, Trackingplan can't detect the data that matters.

  1. Retrieve your snippet from https://app.trackingplan.com/plans/”your TP_ID”/install
    <script type="text/javascript">
        (function(){function a(){try{q.setI…
        Trackingplan.init("YOUR_TP_ID");
    </script>

    This minified example is shortened for the docs: copy the full script with Copy Snippet on your install page. To get your snippet, you need to create an account first. Then replace YOUR_TP_ID with your own Trackingplan ID.

  2. Paste the snippet into the top of the <head> section of all of your pages, before any other analytics snippets or tracking codes.

Once it is installed and you have verified that Trackingplan is collecting data correctly, Trackingplan checks the data you send to your third-party services automatically, without changing or slowing down anything.

How it Works

This keeps your tracking plan up to date and makes inconsistencies and errors easy to spot. The Trackingplan SDK attaches a listener to every tracking request your analytics providers’ SDKs send. The listener runs in the background and is non-blocking, so it never interferes with the original request.

The technique is simple. Our code wraps the JavaScript methods that send those requests. When an analytics service uses them to send tracking data, two things happen:

  1. First, the original request goes to the analytics provider, as always.
  2. Then, without blocking anything, and only if the request URL matches a known analytics domain, a copy goes to our server.

Our script listens to the three methods most often used to talk to analytics providers:

  • XHR: by wrapping the XMLHttpRequest.open and XMLHttpRequest.send functions
  • Pixels: by wrapping the HTMLImageElement.prototype.setAttribute function
  • Beacons: by wrapping the navigator.sendBeacon function

It is the same technique your analytics providers use, and the one browser extensions, testing suites and debugging tools rely on.

Advanced options

Trackingplan’s init call also accepts an options dictionary. Use it to set advanced parameters: tell sources, environments and custom domains apart, or get more out of Trackingplan’s debugging.

Parameter

Description

Default value

Example

sourceAlias

Allows to differentiate between sources

Javascript

"TrackingplanWEB"

environment

Allows to isolate the data between production and testing environments

PRODUCTION

DEV

customDomains

Allows to extend the list of monitored domains. Any request made to these domains will also be forwarded to Trackingplan. Only define a custom domain if your analytics or marketing platform sends data to a non-standard endpoint (for example, a server-side tagging setup or a vendor configured with your own domain). Learn more about custom domains.

{}

{"cusomdomain.com/data/": "ssgtm"}

getDataLayer

Allows you to capture a real-data representation with browser-captured context, acting as a bridge between your website or applications and various analytics tools and helping essential data move between them. If your data layer isn’t named DataLayer (e.g.: customDataLayer) be sure to specify the correct variable name accordingly.

empty

function(){ return window.VARIABLE_NAME; }

debug

Shows Trackingplan debugging information in the console

false

true

tags

Tags allow you to label the data you send to Trackingplan. These are completely customizable, enabling you to distinguish your warnings by their release version, build number app version, test name, etc., debug and perform root-cause analysis on your warnings, or break down event traffic by the values of your tags (country, pageType, etc.)

empty

{"country": "us"}

usePrivacy

Makes Trackingplan automatically encrypt any detected personal data in Trackingplan’s privacy report.

true

true

To set up tags, add the following init(...) parameter to the Trackingplan snippet you already used to install Trackingplan, in your site code or in Google Tag Manager:

Trackingplan.init(..., {
	"tags": {
		"tagName1": "tagValue",
		"tagName2": "tagValue",
		...
	}
})

From then on, all the traffic that reaches Trackingplan from your sites and apps carries these tags.

Using Custom domains

Trackingplan recognizes requests sent to the standard collection domains of the analytics and marketing platforms it supports, automatically. Each domain maps to a Trackingplan parser, which turns the raw requests into the enriched event format you see across the platform.

If your implementation sends data to a custom collection domain instead of the platform's default one, Trackingplan can't identify it automatically. In that case, configure the custom domain when you install Trackingplan.

To configure a custom domain, you need:

  • The custom domain that your implementation sends requests to (for example, your own collection domain instead of the platform's default endpoint).
  • The parser ID that tells Trackingplan which platform those requests belong to.

The parser value is not the name you'll see in Trackingplan. It is the internal identifier that tells Trackingplan how to read requests from that domain.

Some common parser IDs include:

Platform

Parser ID

Server-side Google Tag Manager

ssgtm

Stape

stape

Tealium

tealium

Adobe Analytics

adobe

Adobe Target

adobe_target

Jentis

jentis

Piano

piano

Not sure which parser ID to use? Reach out to the Trackingplan team and we'll help.

Set up Trackingplan with GA4 on Shopify

Shopify no longer offers the native Settings integration for Google Analytics 4 (GA4), so we recommend a custom pixel. It lets Trackingplan capture data beyond the checkout phase.

Step 1: Create a Google Tag Manager Custom Pixel

  1. Open your Google Tag Manager account, and select the account that you want to set up a custom pixel with.
  2. Click Admin, and then click Install Google Tag Manager to open the installation code.
  3. Copy the code block that belongs in the head section of a page.
  4. Remove the HTML tags from the code block. For example, <script></script>.
  5. Go to Custom Pixels in your Shopify admin (you can access it here) and insert the remaining code into a new Shopify Custom Pixel.

    Step 2: Add Trackingplan SDK

  6. Place the Trackingplan SDK snippet at the top of all your custom pixels. Use the snippet below and replace YOUR_TRACKINGPLAN_ID with the ID from your Trackingplan account. We also recommend setting script.async to false so it loads first:
```
(function() {
    const script = document.createElement('script');
    script.src = 'https://cdn.jsdelivr.net/gh/trackingplan/trackingplan.js@latest/trackingplan.min.js';
    script.async = false;
    script.onload = function() {
        Trackingplan.init("YOUR_TRACKINGPLAN_ID", {
            environment: "PRODUCTION",
            tracksEndPoint: "https://eu-tracks.trackingplan.com/v1/",
            // Uncomment and customize the line below if you want to set tags
            // tags: { "gtm_container_version": "{{Container Version}}" }
        });
    };
    document.head.appendChild(script);
})();
```

The global Shopify dataLayer isn't available in Custom Pixels. To share extra data (e.g., the Data Layer) from your website with the checkout phase, use localStorage: it stores and retrieves data reliably inside the sandboxed checkout, much like cookies and consent mode.

For guidance on passing consent mode data, see this article: Shopify Checkout Extensibility. For more on creating a custom pixel with GTM and GA4 in Shopify, see Shopify’s official documentation.

Content Security Policies

Content Security Policies are a header your web server sends to your users' browsers. They declare which dynamic resources may load on your page.

For many websites, it is enough to allow only scripts and styles from your own domain and the tools you use. Complex setups can need more care.

Trackingplan only connects to two subdomains, config.trackingplan.com and tracks.trackingplan.com (or eu-tracks.trackingplan.com depending on your assigned datacenter), and doesn’t run code directly from either of them.

If you are using a default Content Security Policy (CSP), add *.trackingplan.com to your script-src policy.

default-src ... *.trackingplan.com 'unsafe-inline'

For stricter restrictions, add *.trackingplan.com to your connect-src policy. We recommend the template below, so your policies hold up as things change:

connect-src ... *.trackingplan.com 

More questions, or something not working? Contact us and we’ll get back to you as soon as possible.

Was this useful? Write to support@trackingplan.com