Installing and using Google Tag Manager

Difficulty: Advanced | Updated: July 19, 2019

In AdRotate Pro you can track Impressions and Clicks using Google Analytics Events.
Have all your analytics in one place with the power of Google behind it. For this you can use Google Tag Manager available in your Google account. If you prefer to use the Global Site Tag, go there instead.

Using the Google option all statistics are tracked externally, using onload and onClick attributes, AdRotate adds those to your adverts where required and compatible.

For simple banner images, both clicks and impressions can be tracked. Most HTML5/iFrame adverts work for Impressions only. AdRotate Pro can detect the format and add the tracking code by itself in most adverts.

Installing Google Tag Manager

To use Google Tag Manager you need an account with that, but also a Google Analytics account. If you are using Google Tag Manager already you should already have the Google Global Tag installed on your website and you can skip this section. AdRotate uses this code to push it's events to Google Analytics. So make sure it's set up correctly or add it if you haven't already. You can follow the steps below.
Installation of the Global Tag takes only a few minutes.

First log in to your Google Tag Manager Account. Near the upper left of the page there should be an "Admin" button.

Click that and navigate to the Tracking Info section. In there you'll see your Tracking Code.

Copy and paste both codes one by one on your site in the header.

Place both snippets near the wp_head function and <body> tag in your theme's header.php.

Save and upload your theme file. And you're done.

There are also plugins that can add this code for you, so that you don't have to edit the header.php file. Some people prefer this, but that's beyond the scope of this page.

Creating a custom event for AdRotate Professional in Google Tag Manager

For Google Tag Manager to track your adverts correctly you need to create a custom Tag, some Variables and a Trigger. The names and types are very specific and case-sensitive. Create them exactly as instructed here or your tracker will not work accurately.

If you're already familiar with Google Tag Manager this should be rather easy. We're going to set up a Tag with a Trigger and the tag a bunch of custom variables. Nothing crazy, but it takes a little doing to set up.

Creating Variables

For the Event to work we need 5 variables. 4 of these tell Google Analytics which advert the event is about. The other is to easily reference your Google Analytics Account.

In your Google Tag Manager dashboard navigate to Variables.

Click the New button on the right and add 5 variables, one by one.

Make sure you use the following Variable Names exactly as shown here or it will not work. All variables should be a Data Layer Variable. As you can see in the screenshot, I've named the variables something recognizable as well.

  • AdAction
  • AdCategory
  • AdLabel
  • AdValue

Also create one for your Google Analytics to hold your Google Analytics Tracking ID. This variable should be a Google Analytics Settings type.

Creating the Tag

Next we'll create a Tag and Trigger. Navigate to the Tags tab and click New on the right.
In there you select Google Analytics: Universal Analytics for the Tag Type. And Event for the Track Type.

Next to each Tracking Parameter you see a little block icon, click each one and select the corresponding variable for each of them.

Make sure that Non-Interaction is set to True and that you select your Google Analytics Variable for the Google Analytics setting.

Creating a Trigger

If you scroll down a little you can add a Trigger, which is what Tag Manager uses to listen for clicks and impressions on your site.

Add a new trigger and choose Custom Event for the type and name it AdRotatePro. Make sure the spelling is exactly the same or it won't work.

And that should do it. Save everything and publish your updated tag.
You can now head over to Google Analytics and check the Realtime tab to see if things work. For example by loading a few pages with adverts on them, or clicking adverts on your site.

Seeing statistics

When you track stats remotely they are not visible in your AdRotate Dashboard.

You can see your gathered statistics in 2 places in Google Analytics.

  • Realtime -> Events -> Banner
  • Behavior -> Events -> Banner

Check out my Google Analytics page for more information.

Note: The stats in Behavior are delayed by one day (24 hours). Most free/non-professional accounts of Google Analytics have this delay. If stats show up in Realtime, the same stats will eventually show up in Behavior.

Back to AdRotate Manuals

You may be interested in