How to Manage Subscription vs One-Time Purchases
Learn how to trigger events to only fire on subscription vs one-time purchase events
Overview
To fire a tag only on a subscription purchase, you need a way to differentiate if a purchase is one-time or a subscription.
This guide will show how to manage configurations with Elevar.
Client Side Tracking (for Google Tag Manager)
Do you want to:
- Split one-time vs subscription orders in GA/GA4
- Create Subscription conversion for Google Ads (or another channel)
Then follow these steps inside of Google Tag Manager to manage this.
Requires the Custom Pixel for your purchase scripts & Checkout Extensibility
This guide focuses on using the custom pixel for customer events. The selling_plan is now accessible in the datalayer when using the custom pixel and full checkout extensibility including thank you extensibility for Shopify Plus stores. Ensure you are using the customer events settings along with checkout extensibility for purchase tracking.
Note: that this logic does not apply to additional scripts on the order status page.
Create Custom Triggers in GTM:
Navigate to Google Tag Manager > Variable > New
Let's title our variable js - Has Subscription Purchase, select Custom JavaScript as the Variable Type, and input the below in the Custom JavaScript box:
function(){
var products = {{dlv - Thank You Page - ecommerce.purchase.products}};
for (var i = 0; i < products.length; i++){
if (products[i].selling_plan_name != "one-time"){
return true;
}
}
return false;
}
- Navigate to the "Triggers" tab and click on the "New" button.
- Let's title our trigger Event - Subscription Purchase, select Custom Event as the Trigger Type, input dl_purchase as the Event Name, and add the condition for it to fire only when the js - Has Subscription Purchase variable we just created equals 'true'. Save it.
- Duplicate the Event - Subscription Purchase trigger you just created.
- Title this duplicate Event - One-Time Purchase, and update the condition to only fire when the Subscription Purchase variable equals 'false'.
Setup a Subscription Purchase Tag:
- Navigate to Google Tag Manager > Tags > New
- Let's title our tag GA4 Event - Subscription Purchase & select Google Analytics: GA4 Event as the tag type.
- You can then match the tag setup below. Make sure to use the Configuration tag that maps to your intended GA4 Property!
- For the trigger, select the Event - Subscription Purchase trigger you created in Step 1.
- Then save! Voila - you have your Subscription Only Purchase GA tag!
Setup a One-Time Purchase Tag:
-
In Google Tag Manager > Tags > New
-
Let's title our tag GA Event - One Time Purchase & select Google Analytics: GA4 Event as the tag type.
-
You can then match the tag setup below. Make sure to use the Configuration tag that maps to your intended GA4 Property!
-
-
For the trigger, select the Event - One-Time Purchase trigger you created in Step 1.
- Save your tag and be sure to publish your changes in GTM!
You can now use these same triggers and associate to any other tag in GTM.
Limitations
- This setup will not work if you are using the Order Status Page Additional Scripts for tracking your checkout and purchase events. You must be using a custom pixel within Shopify's custom events. This is compatible with Shopify Thank You Page extensibility.
Updated 3 months ago