Reusing Ecommerce Variables in Google Tag Manager
In my previous post, Four Tips for Advertising Pixels in Google Tag Manager, one of the best practices that I outlined for advertising pixels is to re-use existing variables as much as possible. Not only does this make your life easier by saving you from having to update your Data Layer, it also makes your tracking more consistent because different tools are using the same source for their data.
While this is straightforward to accomplish with ‘simple’ interactions like clicking a button or submitting a form, Ecommerce data is more complex. Not only are there more data points to collect, but Google Tag Manager is rather strict about how it wants data presented for Google Analytics.
Fortunately, LunaMetrics has solved much of that complexity for you with our new Enhanced Ecommerce Variable pack, specifically designed to help with adding Ecommerce data to your third-party Tags and pixels. If you have already implemented Enhanced Ecommerce on your website using Google Tag Manager, then you can use this recipe to easily grab key data points about your products, purchases, and other Ecommerce touchpoints for easy use in other tag types.
By using the recommended Enhanced Ecommerce implementation for Google Tag Manager, your data will be structured in a way that makes this type of recipe possible. Ecommerce information is organized and placed on the data layer following the specific instructions, and we can grab it pretty easily with Google Tag Manager variables.
First, some caveats:
- This recipe expects that you are already tracking Ecommerce information in Google Analytics using Enhanced Ecommerce. If you haven’t tracked your Ecommerce yet, or if you’re still using Standard Ecommerce, or if you aren’t using Google Analytics at all, this recipe is not for you.
- This recipe expects that your Enhanced Ecommerce implementation is done through Tag Manager, using the “double checkbox” method. If you are using the “single checkbox” method and using any custom variables, you’re on your own.
- The values that this recipe exposes are only as good as your original implementation. If you haven’t implemented tracking for certain Ecommerce touchpoints yet, this recipe won’t magically track them. And if you’re not passing in specific data points, like tax or shipping totals, this recipe won’t magically grab those values either.
Now, let’s take a look at what you can do!
Your ad partners love it when you track purchases with their advertising pixels. This lets them associate revenue to their ads, which prove value and allow them to optimize better. In fact, most pixel vendors have specific pixel types for tracking Ecommerce conversions. Most of these pixels ask for the some of the same basic data points: Revenue, transaction ID, product SKUs, and occasionally tax, shipping, and the currency code if your site supports multiple currencies.
After importing our recipe, all of these values are available as Tag Manager Variables that you can drop into a tag template or Custom HTML tag, as shown in the screenshot below.
If you have an existing Trigger in Google Tag Manager for your Purchases, such as a Custom Event or a Custom Pageview Trigger, then you should re-use that same trigger for your new advertising pixel. On the other hand, if you track Purchases in Google Analytics with your regular pageview tag, then you should use the new trigger provided in our recipe named Pageview – Purchase which identifies when purchase information has been added to the Data Layer. Note that you should not use more than one trigger, or you run the risk of double-tracking your purchases.
Tracking Add-to-Cart Events
Your advertising partners may like to know when a user added products to their cart but didn’t complete the purchase, because these users are a valuable audience for remarketing campaigns. Similar to Purchase events, most advertising pixels are interested in a common set of data points about items that were added to a cart: usually the SKU and/or name, but also sometimes the price and quantity for more fine-grained targeting.
If you have already added Enhanced Ecommerce tracking to your Add to Cart events, then our recipe makes these values available as Variables that you can drop in to your advertising pixels. Your Trigger for this pixel should be your existing Add to Cart trigger that you use for Enhanced Ecommerce. Unlike Purchases, the Add to Cart event is usually not implemented as part of a pageview tag.
Tracking Products for Other Ecommerce Touchpoints
You may have noticed that the instructions for tracking Purchases and Add to Cart events are pretty similar. This is no coincidence! Most of the heavy lifting for the ad pixels was already done when you implemented Enhanced Ecommerce in the Data Layer. Creating the Tags is as easy as dropping the right Variables into your Tag Template or Custom HTML tag. The most difficult part is managing your Triggers.
As always, you should prefer to re-use existing Triggers in GTM if you have them. You probably already have triggers for on-click events like Add to Cart or Product Click. If these are tied to data layer pushes, you can easily use our JS – Touchpoint Products variable, which will tell you the current products that stage.
Combining Multiple Product Touchpoints into One Tag
Some ad partners want information about the entire purchase lifecycle, at every step from viewing the product all the way to buying. For example, the Facebook pixel has standard events for Product Views, Add to Carts, entering the Checkout flow, and the final Purchase. If you’ve implemented Enhanced Ecommerce, you probably already have tracking around most or all of these Ecommerce touchpoints.
While you can implement each tag individually following the guidelines above, it may be better to have a single Tag in Tag Manager responsible for several pixels. This makes your container smaller and easier to navigate, and if the pixels are very similar, consolidating all of the logic in one place may make your tagging strategy easier to understand. This should not be done if the pixels are very different. Most often, the Purchase event will have its own tag because it needs extra information that don’t apply to the other touchpoints.
Published: November 7, 2017
The key to consolidating multiple pixels into a single tag is using the JS – Ecommerce Touchpoint Name variable provided in our recipe to tell the pixel which touchpoint the pixel represents. Usually, you will have to use a Lookup Table to translate the touchpoint name into the format expected by the pixel. For example, the lookup table below translates the Enhanced Ecommerce Touchpoint Name into standard event names for the Facebook tracking pixel.
This tag will need one Trigger for each touchpoint that you are tracking. See above for guidelines for Triggers. Note that while this tag will have multiple Triggers, it should not have more than one Trigger that correspond to the same Ecommerce touchpoint.
Download and Explore
This latest recipe from LunaMetrics isn’t quite like our others. Importing this pack into your Google Tag Manager won’t change your tracking, but will give you an arsenal of variables that you can reuse or tweak as needed to use consistent data repeatedly with your third-party tags and media pixels.
The post Reusing Ecommerce Variables in Google Tag Manager appeared first on LunaMetrics.