How To Implement Google Analytics & GA4 Server-Side Tracking with Recharge
Elevar powers your data layer and server-side tracking needed to connect GA4 and ReCharge.

Integration Specs
- Channel Accuracy Monitoring
- Requires Elevar Data Layer
- GTM server-side client customizable
- Chrome Extension
- Elevar Server-Side
- GTM Server-Side
- GTM Web Container
What's Included
Events
What customer events are tracked in this integration
- Pageview
- Product View
- Add To Cart
- Initiate Checkout
- Search
- Listing Page
- Purchase
- Base Tag
- Email Signup
Customer Parameters
What customer parameters are tracked in this integration
- customer id
- customer status
- click id
- promo code
- order id
- discount amount
- line items
Steps to Implement
Step 1: Overview
Elevar offers two ways to implement Google Analytics and GA4 server-side tracking:
- Elevar’s server-side tracking
- GTM server-side container (via Elevar)
If you are using your own GTM server-side container connected to Google Cloud then you can follow our related guide on this setup here.
Please note that you have complete control over how your data is being sent to GA including:
- How to manage recurring subscription orders from ReCharge
- Order and product ID type
- What additional channels you want to send to GA — like Facebook and TikTok Shop, Draft Orders, Global orders from third party apps, etc
You can configure each of these in the steps below without modifying any code on your website.
Please note: if you are on the unified Shopify checkout with ReCharge then the setup is the same with our base Google Analytics & GA4 server-side tracking guide for Shopify.
Step 2: Prerequisites
Before you can enable your Google Analytics Destination with ReCharge, you will need to:
- Install Elevar’s Data Layer on your store
- Install Data Layer on ReCharge
- Enable Data Layer Listener Source in Server-Side settings in your Elevar dashboard
- Enable Shopify Notifications Source in Server-Side settings in your Elevar dashboard
You can follow Step 2 from the client-side guide for more details on the data layer installation process.
You should view the Elevar integration details in your ReCharge Apps portal as well:
Step 3: Add Data Layer to ReCharge Checkout Pages
Add the following to the “Enable JavaScript on page 1 of checkout” box
var cartItems = cart_json.line_items; window.dataLayer = window.dataLayer || []; var cartProducts = []; for (var i = 0; i < cartItems.length; i++) { var item = cartItems[i]; cartProducts.push({ 'id': item.sku, 'name': item.title, 'price': item.price, 'quantity': item.quantity, 'product_id':item.product_id, 'variant_id':item.variant_id }); } window.dataLayer.push({ "event": "dl_begin_checkout", "event_id": getEventId(), "cart_total": cart_json.subtotal_price, "ecommerce": { "currencyCode": cart_json.currency, "checkout": { "actionField": {"step":1}, "products": cartProducts } } }); function getEventId(){ var ga = ""; var name = "_ga" + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { var ga = c.substring(name.length, c.length); } } return ga + Date.now(); }
Step 4: Import your Pre-Built Google Analytics Web Tags to Google Tag Manager
Currently, the server-side integration sends only the purchase event via the server. The rest of the GA events come from your browser.
To set up your Universal Analytics Analytics non-purchase events:
- Click here to be taken to the Pre-Built Universal Analytics (for Server-Side) tags.
- Add in your Google Analytics Property ID > Select Download Container
- Log into Google Tag Manager > Select your desired Web GTM Container
- Navigate to Admin > Import Container > Upload the file you just downloaded from Elevar
- Select New under Choose Workspace > titled it Elevar GA Server-Side
- Select Merge > Then select Overwrite > Then Confirm
- [Optional] QA the newly uploaded tags using Google Tag Manager’s Preview Mode
To set up your GA4 Non-Purchase events via the browser:
- Click here to be taken to the Pre-Built GA4 (for Server-Side) tags.
- Add in your GA4 Measurement ID > Select Download Container
- Log into Google Tag Manager > Select your desired Web GTM Container
- Navigate to Admin > Import Container > Upload the file you just downloaded from Elevar
- Select New under Choose Workspace > titled it Elevar GA4 Server-Side
- Select Merge > Then select Overwrite > Then Confirm
- [Optional] QA the newly uploaded tags using Google Tag Manager’s Preview Mode
- Once you’re ready to publish, navigate to the Elevar GA4 Server-Side Workspace > Select Submit at the top right > Then Publish
Step 5: Add Google Analytics as a Server-Side Destination
1. In your Elevar App, navigate to Server-Side > Select Add Destination > Find and select Google Analytics.
2. You’ll be taken to an Overview Page, select Get Started
Step 6: Select your Events
Currently the Elevar Server-Side integration just sends purchase conversions & refunds server-side. We will be releasing our sitewide server-side events into beta soon.
Most likely, you won’t need to adjust anything and can just select Save to continue to the next step.
Note: if you want to send refund data please select order ID in the next step.
Step 7: Select your Transaction Identifier

Step 8: Select your Product Identifier

Select Save to continue to the next step!
Step 9: Block Transactions
This step allows you to control exactly what purchase events are sent to Google Analytics. You can block orders based on Source Channel Names, Order Tags or Order Gateways.
For Google Analytics, instead of blocking orders from being sent, we’d recommend implementing Source / Medium overrides in the Google Analytics ID Step. This will allow your orders in GA to match Shopify better & allow you to bucket offline orders like Recurring Orders or POS orders into their own designated Source / Medium.
You can then create different Views in GA to show “Website Only (No Recurring) Orders” vs “All Orders”.
However, if you do want to block orders from being sent to Google Analytics, here’s how you can do so!
Step 10: Subscription Management
If you sell subscriptions then you have the ability to:
- Send first time orders only
- Send first time and recurring orders where the recurring orders use the attribution from the first order
- Send first time and recurring orders where you can send a custom source/medium/campaign for recurring orders (e.g. “recharge / recurring order”)
Start by Selecting your Shopify Subscription App
Choose if you are using Recharge/OrderGroove or another software.
If you are using another Subscription software that we don’t have listed, here is how to find your Recurring Order tag applied on orders:
- Go to your Shopify Order grid
- Filter the orders by the channel that powers your subscriptions
- Look for orders that have the recurring order tag (this differs by app). For example ReCharge sets “Subscription” and “Subscription Recurring Order” on all recurring orders.
Then Choose to Send Only First Time Orders or Both First & Recurring Orders
If you only want to send first time orders only, select No, block.
If you want to send both first time & recurring orders, select Yes, send all.
If You do Send Recurring Orders, Choose your Desired Recurring Order Attribution Method
Select Yes to use the attribution of the original order for your recurring order. [How does this work?]
Select No, customize attribution, to specify the Source, Medium, & Campaign name for your recurring orders.
Step 11: Select Attribution Method
This setting allows you to override the default last-click UTM parameters from a user visit.
If you are using the Shopify checkout then in many cases Shopify will store attribution data from the user in their path to purchase. It typically looks something like this:
When Shopify has UTM data on the “1st session” and Elevar has UTM data on the session the user converted on then you can choose which UTMs you want sent to Google Analytics.
And if you choose “first touch” but no UTMs exist on Shopify, then Elever will fallback to using UTMs that Elevar stores (and vice versa).
These are all connected to the same user through the GA cookie stored on the order as well.
Yes – this can be quite confusing or mind-blowing to analytics enthusiasts.
However we found that in some cases the UTM data stored on Shopify helped improve the accuracy of transactions.
This article contains a deep dive on the differences that you could see for your own store.
Plus you’ll see how attribution changes unexpectedly.
Step 12: Add Universal Analytics Property ID
Step 13: Add in your GA4 Measurement ID & Secret
Step 14: Setup Source / Medium Overrides
Check to see what Sales Channels you currently use. If you are using Sales Channels beyond the standard Shopify Checkout, (i.e. POS orders, Draft Orders, etc) then you can add source / medium overrides to bucket these orders into their own group in GA.
1. In the Google Analytics ID step, Select Advanced Options.
2. Select Customize by Channel (But you can also customize based on a specific Order Tag or Payment Gateway!)
3. Find the Channel Code (a.k.a. Source_name) for your Sales Channel
4. Input the Channel Code > And input what you’d like to appear as the Source, Medium, & Campaign in Google Analytics.
5. You can press Add Another to add another Override or press Save to continue.
Step 15: Going Live
It’s time to go live!
1. Select Go Live on the Overview Step
2. Be sure your Elevar GA Server-Side workspace in Step 1 is published.
3. Remove your pre-existing GA integration, including inside of your ReCharge settings:
4. Monitor your GA property via real time reports and/or your standard reports
If you have any questions please don’t hesitate to reach out to ask us for help.
Step 1: Install Data Layer to Your Store
In order to deploy Google Analytics via Google Tag Manager tags, you need to have a data layer implemented on your Shopify store that pushes customer, product, and order data that Facebook tags require.
If you don’t have a data layer for your Shopify store yet, then you can utilize Elevar’s data layer for Shopify. It’s a 1-click installation into your theme.
Step 2: Add Data Layer to ReCharge Checkout Pages
Add the following to the “Enable JavaScript on page 1 of checkout” box
var cartItems = cart_json.line_items; window.dataLayer = window.dataLayer || []; var cartProducts = []; for (var i = 0; i < cartItems.length; i++) { var item = cartItems[i]; cartProducts.push({ 'id': item.sku, 'name': item.title, 'price': item.price, 'quantity': item.quantity, 'product_id':item.product_id, 'variant_id':item.variant_id }); } window.dataLayer.push({ "event": "dl_begin_checkout", "event_id": getEventId(), "cart_total": cart_json.subtotal_price, "ecommerce": { "currencyCode": cart_json.currency, "checkout": { "actionField": {"step":1}, "products": cartProducts } } }); function getEventId(){ var ga = ""; var name = "_ga" + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i <ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { var ga = c.substring(name.length, c.length); } } return ga + Date.now(); }
Step 3: Install Data Layer on ReCharge Thank You Page Settings
If you are still using ReCharge checkout (instead of unified checkout) you’ll need to manually add our data layer to the checkout thank you page settings.
Copy the script below and:
- Update the currency code (if needed)
- Input your GTM web container ID to replace the GTM-11111 placeholder
- Paste into your thank you page script configuration in ReCharge checkout settings
{% if first_time_load %} <script> window.dataLayer = window.dataLayer || []; </script> <script> window.dataLayer.push({ 'event': 'dl_subscription_purchase', "event_id": '{{ order_name }}', "user_properties":{ "customer_id": "{{ customer.shopify_customer_id }}", "customer_email": "{{ email }}", "customer_first_name": "{{ first_name }}", "customer_phone": "{{ shipping_address.phone }}", "customer_last_name": "{{ last_name }}", "customer_city": "{{ shipping_address.city }}", "customer_zip": "{{ shipping_address.zip }}", "customer_address_1": "{{ shipping_address.address1 }}", "customer_address_2": "{{ shipping_address.address2 }}", "customer_country": "{{ shipping_address.country }}", "customer_province": "{{ shipping_address.province }}" }, 'ecommerce': { 'currencyCode':'USD', 'purchase': { 'actionField': { 'id': '{{ order_name }}', 'order_name': '{{ order_number }}', 'affiliation': 'ReCharge', 'revenue': {{ total_price }}, 'discount_amount': {{ total_discounts }}, 'tax': {{ total_tax }}, 'shipping': {{ total_shipping }}, 'sub_total': {{subtotal_price}}, 'coupon': '{{ discount_code }}' }, 'products': [ {% for item in line_items %} { 'name': '{{ item.name }}', 'product_id': '{{ item.product_id }}', 'id': '{{ item.sku }}', 'variant_id': '{{ item.variant_id }}', 'price': {{ item.price }}, 'brand': '', 'category': '', 'variant': '{{ item.variant_title }}', 'quantity': {{ item.quantity }} }, {% endfor %} ] } } }); </script> {% endif %} <!-- 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 -->
Step 4: Download Pre-Built Google Analytics Tags
Navigate to your Pre-Built Tag Library & search for Universal Analytics.
Download the container titled Universal Analytics (for Client-Side only).
Repeat this for the GA4 (Client-Side) container.
Step 5: Import Pre-Built Tags into Google Tag Manager Web Container
In Google Tag Manager, navigate to Admin > Import Container.
Choose the Universal Analytics (for Client-Side) container that you downloaded in Step 1.
Import it into a new Workspace. You can title this workspace whatever you’d like. I titled mine Elevar Implementation.
Select Merge > Then elect to Overwrite conflicting tags, triggers, and variables.
Step 6: Update UA Variable in GTM
Update your Universal Analytics variable if you did not enter it when downloading from your Elevar Dashboard.
Step 7: QA & Publish GTM Workspace
Once you’re ready to publish, select the Submit button in GTM.
Then select Publish.
Step 8: Remove your Existing Google Analytics Tracking
If you are using the same Universal Analytics or GA4 property IDs then you’ll need to remove your pre-existing IDs to prevent duplicate tracking.
If you’re using the native Shopify/GA Integration, navigate to Online Store > Preferences > then disable the Google Analytics tracking located under the Google Analytics Section.
If you’ve hard coded your Google Analytics tracking, remove the hard coded script from your Shopify liquid, Shopify Checkout Settings, additional checkouts, and any other locations that Google Tag Manager will be firing on.
You will also need to disable the ReCharge <> Google Analytics setting as well:
Compatible Data Sources

Data Layer
FAQs
View common integration questions
-
Please contact [email protected] and we will enable this setting for you.
-
On average you should expect to see at least 10% more transactions in GA than the native Shopify integration.
-
We typically see 10-20% change in attributed orders in our server-side integration. This means more attribution to paid channels like Google Ads and Facebook and less attribution to direct, organic search, or referrals.