GTM

How to Setup Google Tag Manager DataLayer on ReCharge

Looking to create the GTM dataLayer for use on your ReCharge checkout for your Shopify store? See how!

If you are selling subscriptions on Shopify then chances are you are using ReCharge to do this.

Some of the most popular questions we get from customers of our GTM Suite app for Shopify is:

  • How can I set up GTM on ReCharge?
  • How do I setup the dataLayer on ReCharge?
  • How can I send transactions to Google Analytics via GTM?
  • How can I configure my marketing tags to send from ReCharge via GTM?

I will show you how you can do all of this!

But first a quick background on how ReCharge <> GA works today.

ReCharge <> Google Analytics Native Integration

ReCharge has a native integration with Google Analytics that will send pageview data for each step of their checkout process AND it will send a transaction to Google Analytics for the first time order of a customer.

ga recharge setup

But it’s more important on what this integration does not do.

In addition to not creating a dataLayer on the thank you page to use in 3rd party marketing scripts, this native integration does not send recurring orders to Google Analytics either.

Here’s a hypothetical example of me purchasing a subscription to a Juice Cleanse once/month:

  • August 1st: I place my first order subscribing to get a new cleanse auto-delivered to me monthly. This transaction is sent to Google Analytics.
  • September 1st: My renewal order is created by ReCharge and sent to Shopify automatically without me having to do anything. I receive my email confirmation that my order has been shipped. This transaction IS NOT sent to Google Analytics. 

If you want to send this recurring transaction to Google Analytics then you’ll need to use one of two apps on the Shopify App store: our own Elevar subscription app that sends this recurring order data to GA or Littledata which has their own integration with ReCharge.

Once you’ve taken this step then you will have recurring revenue visualized inside of Google Analytics.

How to Setup GTM + DataLayer on ReCharge

In addition to the native GA integration, ReCharge also has a configuration that allows you to input third party scripts that will fire on the checkout page – just like Shopify has.

This is where I’m going to show you how to build your own dataLayer for GTM on ReCharge.

When logged into ReCharge inside of your Shopify store then go to Settings > Checkout as shown here:

recharge-checkout-options

Then scroll down to find the Thank You Page script settings:

recharge-thank-you-page-scripts

And copy this dataLayer snippet below, including the GTM script at the bottom:

<script>
dataLayer = [];
</script>

<script>
dataLayer.push({
'event': 'subscriptionTransactionComplete',
'CustomerEmail': '{{ email }}',
'CustomerFirstName': '{{ first_name }}',
'CustomerLastName': '{{ last_name }}',
'ecommerce': {
'purchase': {
'actionField': {
'id': '{{ order_name }}', 
'affiliation': 'Snow',
'revenue': {{ total_price }}, 
'tax': {{ total_tax }},
'shipping': {{ total_shipping }},
'coupon': '{{ discount_code }}'
},
'products': [ {% for item in line_items %} { 'name': '{{ item.name }}', 'productId': '{{ item.product_id }}', 'id': '{{ item.sku }}', 'price': {{ item.price }}, 'brand': 'Snow', 'category': '', 'variant': '{{ item.variant_title }}', 'quantity': {{ item.quantity }} }, {% endfor %} ]
}
}
});
</script>

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-1111111');</script>
<!-- End Google Tag Manager -->

You’ll need to update the GTM-1111111 to match your own GTM container ID.

What I have included here is the following:

  1. An event push called subscriptionTransactionComplete which is what you can use as a trigger inside of GTM
  2. Order level customer details (which you can remove if you don’t want/need due to your own GDPR requirements), otherwise these can be hashed in GTM before being sent to another third party
  3. The Google enhanced ecommerce dataLayer structure that includes order details (like revenue) and product line item details

If you are already using our GTM Suite app from the Shopify App Store then these variables (like revenue, etc) will automatically map to the variables we provide in our GTM container.

You will need to create a new event in GTM that looks like this:

subscription transaction gtm event

Which will allow you to configure marketing tags inside of GTM that can be mapped to this trigger.

Here’s one use case to help get your marketing juices going:

We’ve broken out the Facebook (and other third party) tags to send an event from Shopify called “Transaction” and then another event for subscription purchases called “Subscription Purchase”.  This allows our customers to run their CAC, ROAS, and other performance reports separated out by product type.

Bonus: How to Send Transaction Events to GA from ReCharge

We’ve had a few customers come to us with issues that no transactions are being sent from ReCharge to GA for the first order, even with the native GA <> ReCharge integration setup.

We’ve been able to validate this by using the GA Debugger Chrome Extension (it’s a very odd bug!).

But GTM to the rescue: we were able to fix this issue by sending a transaction event from GTM using this same trigger above which looks like this:

ga recharge transaction event

Once published then this will begin sending transaction events to GA!

Interested in having the experts at Elevar assist with your own ReCharge & GTM & GA setup?

Send us an email to sales@getelevar.com and I’ll get you taken care of!

Please feel free to leave questions or comments below.

Thank you!


Brad Redding

Brad, co-founder of Elevar, has lived in eCommerce for over 12 years. He's helped design, build, and optimize over 100 websites in his career. From new retail startups to well-known brands like Le Creuset, Signature Hardware, Rebecca Minkoff, Char-Broil and more, he specializes in data analytics and conversion optimization to help achieve business goals.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Articles