How to Track Internal Promotions with Google Analytics & GTM

🚨 Note: All standard Universal Analytics properties will stop processing new hits on July 1, 2023. 360 Universal Analytics properties will stop processing new hits on October 1, 2023. That’s why it’s recommended to start using Google Analytics 4.

To reap all the benefits of Enhanced Ecommerce in Google Analytics, you need to track internal promotions on your website.

Normally, this is difficult because it would require customizing and deploying extensive Data Layers — but you can work around this hurdle by using a Custom JavaScript Variable instead.

GTM For Beginners

Sign up to the FREE GTM for Beginners Course...

In this guide, we’ll show you how to track Internal Promotions (like banners or lightboxes) with the help of Enhanced Ecommerce and Google Tag Manager. 

An overview of what we will cover in this guide:

🚨 Note: For this tutorial, we’ll be using Google Analytics’ own Enhanced Ecommerce demo shop, which you can also use to follow along.

So let’s jump in!

Internal Promotions in Enhanced Ecommerce Tracking

Enhanced Ecommerce is a special feature in Google Analytics that provides reports on shoppers’ behavior throughout the entire sales cycle. Promotions in Enhanced Ecommerce are marketing elements on your shop website.

AKA, they don’t include ads that you pay for outside your site, and they don’t include product views themselves. (They usually come in the form of banners, category highlights, or other ad-like elements.)

When a user clicks on an internal promotion on your site, they’ll usually be redirected to a product or category page, moving them further along your sales funnel. 

With the Enhanced Ecommerce plugin on Google Analytics, you get a separate set of reports just for promotion tracking. You’ll find these reports under ConversionsE-commerce Marketing Internal Promotions

Access report by navigating to Conversion > E-commerce > Marketing > Internal Promotion

If you have Enhanced Ecommerce tracking installed on your site, this report will track each of your internal promotions (listed by name) with its impressions, clicks, click-through rate (CTR), associated conversions (Transactions), and the resulting Revenue.

Internal Promotion report shows views, clicks, CTR, transactions and the revenue of internal campaigns

You can also use internal promotion tracking for user behavior on non-eCommerce websites. For example, you can track lead generation or internal promotions that lead to other types of conversions.

Why Use a Custom JavaScript Variable?

As we mentioned, proper Enhanced Ecommerce tracking once required extensive Data Layers. This is pretty inaccessible if you don’t have a developer or if you’re not very code-savvy yourself.

But as digital marketers, we can do most Enhanced Ecommerce tracking ourselves (including internal promotion tracking) in Google Tag Manager by using a Custom JavaScript Variable, like the one here:

Sample Custom JavaScript Variable with a built-in tracking mechanism for Google Tag Manager to track promotions in Enhanced Ecommerce tracking

Custom JavaScript Variables provide the information that we want to send over to Google Analytics without needing to mess with Data Layers. They function entirely on Google Tag Manager’s built-in tracking mechanisms.

Without a Custom JavaScript Variable, we would need to deploy promotionClick Data Layers on each page where your promotions appear.

This is because we need to push the promotionClick Data Layer to Google Tag Manager’s Data Layer each time a user clicks that promotion.

Data Layer called promotionClick is pushed to Google Tag Manager’s Data Layer and sent on to Google Analytics

The Custom JavaScript Variable (working together with a click trigger and an element visibility trigger) takes care of this task for us so that we don’t have to do it ourselves. No back-and-forth emails with the developer — just a quick solution inside the graphic user interface of GTM.

In short, a Custom JavaScript Variable simply makes it way easier to track internal promotions with Enhanced Ecommerce.

💡 Top Tip: If you’re using Enhanced Ecommerce but you have Google Analytics installed via the Global Site Tag (Gtag) instead of with Google Tag Manager, check out this guide to learn how to install Google Analytics on your website with GTM

Track Promotion Views Using Element Visibility Triggers

So how do we track internal promotions with these custom variables and triggers in GTM?

The basic process for GTM that we want to set up looks like this:

  • Custom JavaScript Variable listens for promotion-related triggers
  • User sees promotion → Element Visibility trigger pushes promoView Data Layer
  • User clicks promotion → Click trigger pushes promoClick Data Layer
  • GTM sends View & Click data to Google Analytics
  • Google Analytics tracks data as Enhanced Ecommerce Internal Promotions

And at the end, you have detailed reports of who saw your promotions, clicked on them, and made purchase decisions because of them. Good stuff!

So let’s dive into the first step: creating a Custom JavaScript Variable.

Set Up Custom JavaScript Variable for Internal Promotions

In Google Tag Manager, go to Variables and click New.

Build new variable in Google Tag Manager

For the variable type, choose Custom JavaScript.

Choose Custom JavaScript variable to calculate values in the browser

In the code field, enter the following script:

function(){
return
  {
    'ecommerce': {
      'promoClick': {
        'promotions': [
         {
         'id': 'JUNE_PROMO13',
         'name': 'June Sale',
         'creative': 'banner1',
         'position': 'slot1'
         }]
      }
    }
  }
}

(This script is derived from the specifications in the GTM Developers Guide — you can check it out yourself if you want to go a little deeper into this.)

Next, you’ll need to customize this sample Data Layer for your own promotions. To do this, you’ll need to know a little bit about how to read Data Layer information.

If you’re already familiar with this, you’ll notice that this sample includes two promotions: one called JUNEPROMO13 and one called FREE_SHIP13. (Obviously, these are just samples—you’ll substitute these for your own promotions in a moment.)

If you only want to track one promotion, you’ll have to remove one of the items; if you want to track more than two, then you can duplicate items and fill in the values with other promotion data.

In this example, I just want to show you how to track one promotion. I’ll get rid of the first one by deleting lines 6 – 11. 

Remove the first promotion which contains JUNE_PROMO13

Next comes the individual promotion customization. Every unique promotion needs its own ID and name (although these will remain the same if one promotion appears across several pages).

You can use ID and naming conventions like in the GTM Developers Guide or use any way that works for you — it doesn’t matter as long as you’re consistent.

Personally, I give my promotions ID numbers and then give them a more descriptive name for the content or product it’s promoting.

Change out the name and ID for your campaign in the JavaScript code

If you’re running multiple versions or locations for a promotion, you may also want to add values for creative and position in this script.

You’ll be able to differentiate between different creative and position values with the same name using Secondary Dimensions in your Google Analytics reports. But especially if you’re just running one promotion on your site, these are optional.

Finally, give your Custom JavaScript Variable a name and click Save.

Customize the creative and position in the JavaScript, then rename the variable

Test Your Custom JavaScript Variable

In Google Tag Manager, go into preview mode to confirm that we have it correctly formatted and functioning. 

In your event tree, click on DOM Ready and check out the Variables tab.

Here, we should see our Custom JavaScript Variable with object as the Return Type, and it shows the Enhanced Ecommerce tracking object that we scripted in the previous step.

Check that your custom JavaScript variable has the correct return type and value in GTM preview mode

Create a Google Analytics Event Tag

So now Google Tag Manager has the data that Google Analytics needs in order to track internal promotions… whew. So now we need to somehow transfer that data to Google Analytics.

How would we do that? Well, through a pretty simple Google Analytics Tag. 

In Google Tag Manager, go to Tags and click New

Create a New Google Analytics tag in GTM

Name your Tag so that you know what it tracks and where it sends its data. Then, select the Google Analytics Tag type appropriate to your GA property — either Universal Analytics or GA4.

(In this case, I’m using the Google Analytics – Universal Analytics type to go with my Universal Analytics property.)

Name the new Google Analytics tag with and choose the tag type Google Analytics - Universal Analytics

For the Track Type, choose Event.

Next, we get to select our tracking parameters. For the Category, you can call it Enhanced Ecommerce (I abbreviated mine as EE). For the Action, we’ll use PromoView.

It doesn’t really matter what you put in here as long as it helps you identify your data. The parameters just describe your event in your Google Analytics report so that you can sort and analyze data. 

Choose the Track Type Event and name Category as EE and Action as PromoView

Choose True for the Non-Interaction Hit to avoid messing with your bounce rate data. Then, choose your Google Analytics Settings variable (if you don’t have one, see our guide here) so that your data goes to the right account.

Next, we need to tell this Tag to pick up the Enhanced Ecommerce tracking data that we prepared. Check the box for Enable override settings in this tag and then click the More Settings dropdown. 

Set Non-interaction Hit to True, select your Google Analytics settings variable, and enable overriding settings in this tag

Under the E-commerce section, set Enable Enhanced Ecommerce Features to True so that the Tag knows to look for this specific kind of data.

Then, you have to tell the Tag where to look for this data. If you weren’t using a Custom JavaScript Variable and instead had deployed the appropriate Data Layers you would check the Use Data Layer Box.

But the simpler method that we’ve already set up is to use your Custom JavaScript Variable. So under the dropdown Read Data from Variable, select your prepared variable. 

Set Enable Enhanced Ecommerce Features to true and Read Data from the Custom JavaScript Variable created earlier

🚨 Note: When testing this Tag, go to Advanced Configurations and set Use Debug Version to True. This will transport information into our browser’s developer tool while in preview mode so that we can see the data being sent to Google Analytics. When you publish the Tag, go back and set it to False because we don’t want to have that data always in the debug console. 

Lastly, we just need to choose a Trigger. If you use the All Pages trigger, that would obviously mean that the Tag would be triggered on all pages across the website.

This approach is clunky and doesn’t account very well for promotions that might be below the fold (and therefore not actually viewed by the user).

Instead, we want to set up a custom Element Visibility trigger that fires whenever a user actually sees the promotion.

Set Up Element Visibility Trigger

We can build a brand new trigger without leaving the Tag configuration window. Click on the trigger box to open your trigger options, then click the plus sign ( + ) to create a new trigger.

Build a new trigger by clicking the plus sign

As for the Trigger type, scroll down and choose Element Visibility. 

Choose trigger type Element Visibility under User Engagement

Now we can select a method to trigger this — usually either an ID or a CSS selector.

Obviously, you would need to know a little bit of CSS and figure out what the right selector is. It’s a little simpler to just find its ID in the HTML, so select that and go to the promotion on your website to Inspect it (right-click).

Inspect Elements shows the appearance and content of a web page

Hover over the promotion element to find its HTML markup. This one has an ID called media_image-2, which I’ll copy to use in my trigger.

Elements panel shows HTML markup where the id media_image-2 is located

Paste the ID into the Element ID field, then select how often the trigger should be allowed to fire (I’ll choose Once per page for this example).

I usually recommend setting the Minimum Percent Visible to 50% since users will probably visually register the element at that point, but this can depend on your individual elements.

Choose ID as Selection method with the Element ID media_image-2 and fires the trigger once per page with Minimum Percent Visibility of 50%

Finally, just give your trigger an informative name and click Save.

Name the trigger and save

Test Your Enhanced Ecommerce Internal Promotion View Tracking

Finally, let’s test our Enhanced Ecommerce internal promotion tracking in GTM preview mode.

While in preview mode, navigate and scroll to the promotion you tagged. When you reach that promotion, you should see your Element Visibility trigger fire along with your promotion view Tag.

gtm.elementVisibility is fired together with the Tag

If you set Use Debug Version to True in the Tag’s Advanced Settings, you should also be able to Inspect your promotion again to see what data the Tag will send to Google Analytics.

In your developer tools console, you should see what data the Tag sent to Google Analytics. The Enhanced Ecommerce tracking data should include your Tag (gtm5.ec:addPromo in this example), the ID, the name, and so on.

Developer Tools Console shows the Enhanced Ecommerce tracking data

We can also see this in our Google Analytics account under Real-Time → Events. You should see your event appear with the parameters you provided in your Tag configuration.

This data in our Google Analytics account tells us that GTM did send some data — but did it actually pick up the right Enhanced Ecommerce data?

To check this, go to Conversions → eCommerce → Marketing → Internal Promotions.

Navigate to Conversions > E-commerce > Marketing > Internal Promotions

To make sure that you find the right data push, set the report date range to just today’s date. 

Set the report date filter to today’s date

Track Promotion Clicks Using Click Triggers

Promotions aren’t that useful if users just see them — they have to click them! So our next step is to track clicks on your internal promotions using Enhanced Ecommerce click triggers.

We already had a closer look at how to set up a Data Layer for a custom JavaScript variable that tracks promotion views. Now, we just apply that same skill to promotion clicks.

The Data Layer for the promoClick Enhanced Ecommerce action will work similarly. Let’s dive into its configuration.

Data Layer that contains an event called promoClick

Create Enhanced Ecommerce Promo Click

Start by making a new Custom JavaScript variable. (You can duplicate your promotion view variable to speed some of this up — just make sure to rename it for promotion clicks.)

The specifications in the GTM Developers Guide include a sample Data Layer for Measuring Promotion Clicks. You can copy and paste the following template code, which is pulled from their sample:

function(){
return
  {
    'ecommerce': {
      'promoClick': {
        'promotions': [
         {
         'id': 'JUNE_PROMO13',
         'name': 'June Sale',
         'creative': 'banner1',
         'position': 'slot1'
         }]
      }
    }
  }
}

Be careful! Your promotion’s ID, name, creative, and position labels all need to match the ones in your promotion view variable.

Make sure to replace values in the above script such as ‘JUNE_PROMO13’ and ‘slot1’ with the correct corresponding values for your promotion. Otherwise, your data reports won’t be filled in correctly.

Save data that is copied from Custom JavaScript variable

Build a Promo Click Event Tag

Now that we have a custom JavaScript variable prepared, we need to build a Tag that sends that variable data to Google Analytics.

Go to Tags and click New (or, if you followed along with the first half of this guide, you can simply open and Copy your promotion view Tag). 

Name your new Tag to identify it as an event for promotion clicks (in my case, I use GA – Event – EE Promo Click).

You should also change the Event Tracking Parameters to match your new event. I’ll keep the Category for mine as EE, but I’ll change the Action to be called PromoClick.

Event Tag named GA - Event - EE Promo Click with event tracking parameter PromoClick

Next, scroll down to the E-commerce settings. Under Read Data from Variable, select your new promotion click variable that you created in the last section.

Finally, we need to select a new trigger for this Tag. (If you copied this Tag from your promotion view Tag, make sure to remove the existing visibility trigger.) Click on the plus icon ( + ) to create a new trigger for this Tag.

Build a new trigger by clicking the plus sign

For now, we’ll just have to build a generic click trigger—we’ll test and revise it to specify our promotion in a moment. Scroll down until you find the Click triggers and select All Elements.

Choose All Elements click trigger

Give it a name so that you know this is a generic click trigger and hit Save.

Name trigger for generic click

Before we move on to testing, though, we need to configure some built-in variables. Go to Variables and click on Configure.

Configure Built-in Variables in GTM

Then, enable all the built-in variables under Clicks such as the Click Element, Click ID, and so on. These will help us identify our promotion element so that we can make our click trigger more specific.

Configure Built-In Variables by enabling all variables under Clicks

Restrict Your Trigger to Fire on Only Ad Clicks

In GTM preview mode, open the webpage that contains your promotion and click on it. Remember that the generic click trigger will fire your tag no matter where you click on the page, so make sure that you’ve really clicked on your promotion!

You should see the trigger and Tag appear in your preview console. Click on the click event, then go to the Variables tab.

Scroll down through the variables until you find the built-in click variables that we enabled. You’ll notice that some of the values are more distinctive than others.

In my example, the Click Classes variable has a value containing the string wp-image-71 — very distinctive and unlikely to be shared with other potential clicks. (Note that most useful variables and values in your case will be different!)

Gtm.click event variable Click Classes contains value wp-image-71

Since the wp-image-71 string is unique, we’ll use this to refine our generic click trigger to a promotion click trigger.

Go back to Triggers in the GTM workspace and open your generic click trigger.

Rename it to specify that this trigger is now just for clicks on your promotion and change the trigger to fire on Some Clicks.

Then, use the next field to tell this trigger to fire when your selected variable contains or matches the value for your promotion. In this example, mine fires when Click Classes contains wp-image-71.

New trigger fires when user clicks Ad where Click Classes contains wp-image-71

Test Your Enhanced Ecommerce Internal Promotion Click Tracking

As always, the final step is to test your tracking for quality.

Back in preview mode, click on your promotion. If everything is working correctly so far, you should see the trigger and your Tag fire when you click the promotion (and not when you click anywhere else).

Promo Click Tag fires when user clicks on Ad

Next, you need to make sure that Google Analytics is actually receiving the data that Google Tag Manager is sending.

In Google Analytics, go to Real-Time → Events. You should be able to identify your promotion click event based on the parameters you assigned to it in your Tag configuration.

Real-Time Events report shows promotion ad click

If you want to ensure that these events include all your Enhanced Ecommerce tracking data, you can take one more step.

On your webpage, right-click and select Inspect.

Right-click and Inspect Elements to open Developer Tools

This will open up your Developer Tools. Under the Console tab, you’ll find all your Google Analytics information (you may need to reload the page to see everything properly).

If you scroll down, you should see that your events have fired when you view or click on your promotion.

Developer Tools Console shows that Google Analytics runs command “PromoView”

Scroll down a little further to find the Enhanced Ecommerce metrics like creative, id, name, and position. If these are populated correctly, then you can rest assured that your tracking is properly configured.

Developer Tools Console Google Analytics data includes Enhanced Ecommerce

We can dive a little deeper with this data. Back in your Internal Promotions report in Google Analytics, set the date filter to today’s date and click Apply.

Set the date to today’s date then Apply

Here, you should see that your Internal Promotion Clicks have also registered. So this data was transferred correctly.

Reports that show Internal Promotion Clicks have already been received

Summary

All right, so there you have it! That’s the full tutorial on internal promotion tracking for Enhanced Ecommerce using Google Tag Manager.

It’s certainly a lot to cover, but tracking the success of your advertisements is important even if you’re not paying for that space somewhere outside your website. Lost conversions are lost revenue, so make sure to track internal promotions and maximize your conversions!

Another useful thing to learn is how to track conversion value with Google Tag Manager and how to send this data to other marketing tools.

Do you have any other strategies for tracking internal promotion campaign success? Have you tried this method? I’d love to hear about your experience! Let me know in the comments below.

JOIN US!

Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jessie
Jessie
2 months ago

Hi Julian,

Thank you so much for the detailed explaination! I have a question here: what if we have two promotional banners and would like to track them? Do I need to then create a promo view and promo click variables for each banner, and have the variables added to the tag with trigger only be fired for that banner? Or I can keep both in one promo view and one promo click JavaScript variable? Looking forward to your answer 🙂

Tulio
Tulio
1 month ago

Is it possible to create more promotional events and use them in the report?
I managed to create the events and send the items array with the promotion_id parameter, but how can I use them in the report?

https://support.google.com/analytics/thread/211162086?hl=en&sjid=8093423347735736323-AP

Greg
Greg
1 month ago

Hello, is there a way to do this in GA4? I didn’t find any useful information about that.

Sofiia Bychkovska
Admin
1 month ago
Reply to  Greg

Hi Greg, yes, you can track it in GA4. I would refer to the official documentation. You would need to send a view_promotion event and push products and their attributes along with it.

Blog Categories

Ready to switch to GA4? Subscribe & Get our FREE Course

GA4 for Beginners Course

Want to find the Best Sources for Learning GTM? Subscribe & Get our FREE Resource Guide

Google Tag Manager FREE Resource Guide

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.