Skip to content
English
  • There are no suggestions because the search field is empty.

How do I exclude the tracking code from specific pages using Google Tag Manager?

You might not want Leadinfo to track every page on your website. Common reasons: a login page or client portal that your own team visits constantly, a staging or test environment on the same domain, a checkout or payment page, or a one-off campaign landing page you don't want cluttering your inbox. Whatever the reason, you can exclude specific pages using a trigger in Google Tag Manager.

There are two ways to do this, depending on your situation:

  1. You already track your whole site and want to exclude one or more pages
  2. You're installing Leadinfo for the first time and only want to exclude some pages from the start 

Excluding pages from an existing Leadinfo installation

Step 1: Open your Leadinfo trigger in GTM

Go to your Google Tag Manager account and select the container your website runs in. Click on "Triggers" in the left-hand menu and open the trigger that's currently linked to your Leadinfo tag. In most cases, this is the default "All Pages" trigger.

GTM trigger 1

Step 2: Create a new, more specific trigger

Don't edit the "All Pages" trigger directly, since other tags may depend on it. Instead, click "New" to create a fresh trigger, and give it a clear name, for example "Leadinfo - All Pages Except Excluded".

Click on "Trigger Configuration" and choose "Page View" as the trigger type.

GTM- all pages except excluded 1

Step 3: Set the exclusion rule

Select "Some Page Views", then choose "Page Path" from the dropdown and set the condition to "Does not contain". Fill in the part of the URL you want to exclude, for example /login.

GTM- excl. login 1

Note 📝: If you only need to exclude one page, "Does not contain" is enough. If you need to exclude several pages at once, use "Does not match RegEx" instead, and combine the paths with a pipe (|), for example: ^/login|^/staging|^/internal-portal. This tells Google Tag Manager to skip the trigger on any page whose path starts with one of those values.

Step 4: Swap the trigger on your Leadinfo tag

Go to "Tags" and open your Leadinfo tag. Click on "Triggering", remove the "All Pages" trigger, and add the new trigger you just created instead. Save the tag.

GTM-all pages trigger 1

Step 5: Test before you publish

Click "Preview" in the top right corner and open your website in the preview window. Visit one of the pages you excluded and confirm the Leadinfo tag does not appear under "Tags Fired". Then visit a page you still want to track and confirm it does fire.

 

Step 6: Publish your changes

Once you're confident it works as expected, click "Submit", give the version a clear name, and click "Publish".

gtm-submit-changes.jpg 1

Excluding pages while installing Leadinfo for the first time

If you're setting up Leadinfo for the first time and already know which pages should never be tracked, you can build the exclusion straight into your setup instead of starting with "All Pages".

Step 1: Copy the tracking code 

Copy the tracking code from the portal. You'll find it under "Settings".

Tracking code- copy

Step 2: Create your trigger

In Google Tag Manager, go to "Triggers" and click "New". Choose "Page View" as the trigger type, select "Some Page Views", and set "Page Path" to "Does not match RegEx". Add the paths you want to exclude, separated by a pipe (|).

GTM- all pages except excluded 1

Step 3: Create your tag

Go to "Tags", click "New", and give your tag a clear name, for example "Leadinfo Tag". Click "Tag Configuration", select "Custom HTML", and paste the code from Step 1.

gtm-new-tag-custom-html.jpg 1

Step 4: Add your trigger

Click "Triggering" and select the trigger you created in Step 2. Save the tag.

gtm-tag-triggering-selected.jpg 1

Step 5: Publish

Click "Submit" in the top right corner, name your version, and click "Publish".

gtm-submit-changes.jpg 1

Note 📝: Always test one trigger condition per exclusion rather than stacking several conditions into one. Google Tag Manager treats multiple conditions in a single trigger as AND, not OR - so a trigger set to exclude "contains /login" AND "contains /staging" will only fire on pages that match both, which is rarely what you want. Use the pipe-separated RegEx method above, or a separate trigger per page, to be safe.

Do you have questions about excluding pages from tracking? Contact our team via support@leadinfo.com.