Google Tag Manager for CiviCRM

2023-05-16 01:09
Written by
rebeccatregenna - member of the CiviCRM community - view blog guidelines

Simple conversion tracking for your contribution and event pages

No doubt many organisations use Google Analytics and whilst they probably have lots of tracking in place, we established that current extensions and functionality for CiviCRM did not allow putting monetary value to conversions.

Especially for organisations that receive Google Ad Grants this is highly important as it’s a compliance requirement for grants. In order to use Ad Grants to drive meaningful impact, accounts must have conversion tracking set up following tailored requirements intended to suit the needs of nonprofits. Examples of meaningful conversion goals include donations, purchases, ticket sales, membership registrations, email sign-ups, etc.

We reviewed options and spoke to some organisations and found out that quite a few already had Google Tag Manager (GTM) set up which allows user to capture transactional data in a custom layer so we decided to write an extension that adds these layers automatically to contribution and event thank you pages rather than having to inject custom code in page templates.

For now we have gone with some basic data layer variables to be included (page title, total amount, currency, frequency, financial type and campaign) - all you need is install and enable the extension and add your Google Tag Manager ID in the configuration settings.

Once in place, you are able to create your relevant GTM events.

A known limitation is that the data is only sent on the initial transaction by each user. It won’t send data when repeating subscription transactions are taken automatically.

How it works

The idea is that information from CiviCRM thank you pages should be made available when a transaction has been successfully completed. The kind of data we are interested in includes:

  • Financial value
  • Currency
  • Transaction type: e.g., one-off donation, monthly subscription sign-up, annual subscription sign-up.

Importantly, to comply with privacy constraints, we don’t want to expose any personally identifiable information (PII) such as name, address, credit card details, etc.

This data is available to CiviCRM but is not easy to get at for use with other tools such as Google Analytics.

To make this work, the extension listens for a successful transaction within CiviCRM. When the data becomes available, it exposes this within the “success” page via the data layer.

The data can be picked up by other tools and passed on as appropriate. For example, Google Tag Manager can be configured to look out for the specific data we are exposing. This can then be passed onto Google Analytics, or any other tool that can be configured to receive data from Google Tag Manager.

Of course, as the data is exposed in a standard-format data layer variable, tools other than Google Tag Manager could also be used to listen for the data.

You can find guidance on how to set up the data layer variables, GA4 triggers and GA4 tags in the extension documentation.

All and any feedback is welcome and if you need help getting started, please feel free to get in touch by posting on CiviCRM StackExchange or use the user support channel. You could also tag one of us @rebeccatregenna or @kurund and we will be happy to support you.

Filed under


Okaaayy - but you should be aware that using this kind of tracking technology is in general quite problematic regarding privacy. Google's tracking technology definitely is capable to link page views to individuals etc.. And although I know very well that many web designers are not so careful in this respect - within the EU, I fear using this kind of tracking features might be not acceptable in regards of GDPR compliance.

Or have I misunderstood something?