Set up Google Tag Manager

In this video, we’ll show you how to set up a Google Tag Manager account, where to find your Retention.com snippet script code, how to add it to your Google Tag Manager, and how to set up different types of triggering events in Google Tag Manager.

How to set up Google Tag Manager account

To set up Google Tag Manager, you’ll first need to create a free account and connect it to an existing Google account.

1. Go to the Google Tag Manager site, and click Create Account.

2. Fill out the Account Setup information with your Account Name, Country, Container name — which is your website address — and your Target platform. Then, click Create.

3. After you’ve read the service agreement, click Yes.

4. Paste the code onto every page of your website. Paste the <head> code to the top of your pages and the <body> code after the body tag. If you have questions about adding the code to your page, click Quick Start Guide

Where to find your Retention.com snippet script

1. From your Retention.com Dashboard, click Code Script.  Then, click View Your Script.

2. Check the box next to Collection, and then click Copy Code </>. You’ll see a green box in the top right-hand corner telling you the code was copied to your clipboard.

Copy Collection

Remember: You can’t check multiple boxes for scripts or you will get an error message. You can only copy one at a time.

How to add snippet script

1. Log in to Google Tag Manager. Click New Tag.

2. You can give the tag a title at the top. Click the pencil image in the Tag Configuration section.

3. Click Custom HTML under Custom.

4. Paste your Retention script into the HTML box.

5. You will need to choose a trigger at the bottom to make the tag fire. Click the pencil icon in the Triggering section.

6. Choose a trigger, such as page views on all pages.

Note for SPA/React sites: You should set your Triggers for All Pages as seen above, as well as All History Events:

7. Once you have chosen a trigger, click Save in the top right.

8. After you’ve added the script to Google Tag Manager, go back to Code Script and click the edit icon next to Authorized Domains.

9. Paste the domain/URL in the text box where you added the script, and click Save Changes.

It will be highlighted in green if the script is properly installed—and in orange if the script is not properly added.

How to suppress form submissions

You can set a Trigger in Google Tag Manager to suppress visitors who submit their email address via a form or pop-up on your site.

1. From your Google Tag Manager Workspace, click Triggers > New.

2. Click in the box to choose a trigger type, and select Form Submission.

3. Give the form a name at the top. Choose Check Validation. To enable the trigger on all pages (recommended), use this logic:

Page Path > contains > /

4. You will also need to know what other forms are coming to your site so you can exclude those. That keeps the suppression script from firing when those forms/pixels come to your site (instead of only on the form submission). Choose Form URL > does not contain > (the form URL source).

If Facebook is enabled on your site, it uses a form submission pixel that can cause this Trigger to fire even when the site form isn’t submitted.

To prevent that from happening, use this logic:

The trigger fires on Some Forms

Fire this trigger when an Event occurs and all of these conditions are true:

Form URL > does not contain > facebook

5. You will then need to create a Tag for this trigger. From your Workspace, click Tag > New.

6. Click inside the Tag Configuration box and choose Custom HTML as the tag type.

7. Give the Tag a name at the top and then paste your suppression script from Retention.com in the box. (Find your suppression script by going to Code Script > View Your Script > Suppression > Copy Code in Retention.com.)

8. Click the Triggering box at the bottom and choose the form submission trigger you created in the previous steps.

9. Click Save.

10. Make sure this container version is published and set as live.

How to suppress Klaviyo form submissions

To suppress a Klaviyo form submission, paste this script in Google Tag Manager below where you have the collection script in the Tag.

window.addEventListener("klaviyoForms", function(e) {
  if (e.detail.type == 'submit') {
    geq.suppress();
  }
});

If the Tag with the collection script has triggers that delay the script to fire (ex. timed or page view triggers), create a separate Tag for this suppression script. It will only fire when someone submits the Klaviyo form on your domain.

Note: The base script must be firing on all page views for this to work.

How to fire script after X seconds on a page using a timed trigger

1. To set your script to fire after a certain amount of time on a page, click in the Triggering box. This will determine which pages will fire the Retention.com script.

2. Click the plus sign in the top right to configure your triggers.

3. Click the Trigger Configuration box. Then, choose Timer.

4. Name the trigger at the top. To get more targeted leads from your homepage, set the trigger to fire after 5 seconds, which would mean 5000 for the Interval. You’d never fire the script more than once, so type 1 in the Limit. Then, under Enable this trigger when all of these conditions are true, choose Page Path, equals and type /homepage/. When you’re finished, click Save.

Note: You cannot trigger multiple URLs via a single trigger in Google Tag Manager. You will need to either add multiple triggers or use a regex.

How to fire base script immediately

If you set a trigger to only fire your collection script based on a time delay, page views, or other factor that keeps it from firing immediately—but also have other scripts on your site that need to fire immediately such as the Add to Cart or Product View scripts—you will need to create a Tag for our base script. The base script must be present/fire before any other script will be able to fire, and it does not collect contacts.

1. Follow the steps above for “How to add snippet script.” When you paste the collection script in the HTML box (Step 4), delete ‘<script>geq.page()</script>’ from the bottom line:

That will leave you with only the base script:

Remember: You will need to use the script from your account, as the example above does not have your account’s key.

2. Add a Trigger to fire this Tag on All Page Views. This script will not collect contacts and only needs to be added if you don’t have the collection script firing immediately on pages where you want to use the Add to Cart or Product View scripts.

How to set script to fire immediately on other pages

To have another page fire the script immediately, instead of waiting 5 seconds like in the last example, you’ll need to set a new trigger.

1. To set a new trigger for your product pages, click the plus sign in the Triggering section.

2. Click the plus sign again in the top right-hand corner. 

3. Click the Trigger Configuration box and then choose Page View.

4. Name the trigger at the top, and click Some Page Views. Choose Page Path, contains, and then type the path for your chosen products (ex. /products). From our experience, the best results come from the highest-margin products. Hit the plus sign next to the first product to add more lines of product pages you want to fire the script on. Click Save.

How to exclude traffic by referral source

1. To exclude traffic by referral source, start by creating a new trigger. Click the plus sign in Triggering.

2. Click the plus sign.

3. Name it “Exclude” and then the source name (ex. Exclude Taboola). Click in the Trigger Configuration box. Choose Custom Event as the trigger type.

4. Give the event a name (Taboola). Change it to Some Custom Events and then choose Referrer, does not contain and then the name of the source, which would be Taboola in this example. Then, click Save at the top.

5. Once the trigger is saved, click New Tag.

6. Name the tag “Exclude Taboola,” or whatever the source name is. Click in the Tag Configuration box, and choose Custom HTML.

7. Paste your Retention.com script in the HTML box. Click in the Triggering box.

8. Choose the Exclude Taboola trigger you created, and click Save.

How to set your script to fire after a specific number of page views

To fire a trigger after a certain number of page views, you’ll need to first create a new variable.

1. Click Variables and then New.

2. Click in the Variable Configuration box, and choose 1st Party Cookie.

3. Name the variable Cookie – Page Count at the top and the Cookie Name Page Count. Then, under Format Value, put Convert null to as zero and Convert undefined to as zero, and click Save.

4. You’ll then need to create a Custom HTML Tag to read the value in the variable. To do that, go through the Tag steps again: New Tag > Tag Configuration > Custom HTML. Paste the HTML code you create that includes the variable and number of page views you set in the box.

5. You’ll need to add a trigger for the Tag to fire, so click the Triggering box > plus sign > Trigger Configuration > Page View.

6. Name the trigger (ex. Page View Trigger). Select Some Page Views. Then, set these conditions:

Page Count > greater than > 1 (adjust the variable to whatever you used and the number to how many pages you want them to view before it fires).

Remember: The number used here needs to match the one in the custom HTML code you used.

7. Click Save.