Enable GTM Integration in Chargebee.js

Modified on: Tue, 21 Mar, 2023 at 10:35 PM

Note: GTM integration is for recording customer interactions with Chargebee checkout and portal. Backend operations such as subscription renewals do not trigger any events to GTM. 

You may integrate Chargebee with GTM via drop-in script or API.

A. Using Drop-in Script

Enable the data-cb-gtm-enabled attribute to true when invoking Chargebee.js in the page headers of your site.

<script src="https://js.chargebee.com/v2/chargebee.js"
data-cb-site="you-chargebee-subdomain" data-cb-gtm-enabled="true">
</script>

Note: Replace your-chargebee-subdomain in the code snippets on this page with your Chargebee site subdomain names.
Eg. If your Chargebee site is bigshopper-test.chargebee.com, then replace your-chargebee-subdomain with bigshopper-test.

B. Using API

Pass the enableGTMTracking parameter as true when initializing the Chargebee instance.

var chargebeeInstance = Chargebee.init({
    site: "your-chargebee-subdomain",
    enableGTMTracking: true
});


Google Universal Analytics is getting deprecated and will stop processing data on July 1, 2023. Google has introduced a new analytics engine Google Analytics 4 (GA4) that offers new and advanced features that can help you gain a deeper understanding of your website visitors' behavior, such as event tracking, machine learning, and cross-device tracking. With the new setup of GA4 and Chargebee-hosted pages it leverage the capabilities to analyze and optimize your website's performance, providing you with a competitive edge in the subscription business. 

If your site is configured with Google Universal Analytics version, then you can refer to this link to migrate to Google Analytics 4.

If you're using Google Tag Manager to connect to your Google Analytics 4, we recommend that you use this separate integrationand never both.


Other Important Links

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.
×