Target users through Google Analytics and GTM

Follow this step-by-step guide to segment your audience with Tag Manager and Google Analytics

You can use Google Tag Manager to create and publish triggers and tags that allow you to track events such as button clicks on your site. You can then create segments in Google Analytics to target users who meet certain conditions related to these events. For example, you may want to track users who are clicking on a "Add to cart" button on your site but who are not clicking the "Checkout" button.

Below is a sample workflow of how you can start tracking an event and then target users with Xtremepush.


Integrate Google Analytics first

Make sure that you have completed the Google Analytics integration for your project.

Firing an event using Google Tag Manager

In this example, we will look at firing an event when the user clicks a specific button. On our example website we have a button called 'Take action'.


If we inspect this element using the browser's developer tools we are able to see that it has a link that references /take-action-bedford/.


Next go to Google Tag Manager to create a trigger and tag to fire this event.

Create the Tag Manager trigger

Add a new trigger (select Trigger from the left side menu > New).


This trigger should have a suitable name like "Take Action clicks" that will allow you to identify it later. Click on the trigger to create it. The trigger type should be Click > All elements.


The really important setting to make this trigger fire when the button is clicked is the fire on condition.

Select that this trigger fires on some clicks. In our example we use a condition based on the fact that the page URL contains the element shown earlier: /take-action-bedford/.


To fire this trigger when the Take Action button is pressed we have added a condition based on the page URL as shown here.

Save this trigger (click on Save) for use in a tag that will fire the take-action event.

Create the Tag Manager tag

Navigate to the tags section of Google Tag Manager (main left menu > Tags) and click New to create a new take action event tag.


After clicking New, give your tag a suitable name like "Take Action Event". Click on Tag configuration and select Google Analytics: Universal Analytics as the product.

Set the track type as Event. Category should be something suitable, in this example we are categorising this event as a Nav event. Choose an Action name you will be able to recognise (such as TakeAction) and using {{Click URL}} as the label. Leave the Value option blank and set Non-interaction hit as false. Finally select the Google Analytics settings that you would have previously created when you integrated Google Analytics with GTM.


Then click on Triggering and select the custom event that you previously created (Take action clicks).


Once you have added the correct trigger you can save your tag.

Check Tag Manager variables

Before publishing the changes you would need to review your enabled variables.

The trigger and tag that you just created uses some click variables, so you should navigate to the variables section of Tag manager (click on Variables on the left menu > Configure) to make sure that all the options available are selected (Click Element, Click Classes, Click ID, Click Target, Click URL, Click Text).


Publish and test

Now once you publish your Google Tag Manager changes, go to the sample site and click the Take Action button, you will be able to see Take Action events in Google Analytics by navigating to RealTime > Events.


You can now create a Google analytics segment using this event.

Creating a segment in Google Analytics

To do so, navigate to Admin > Segments > New segment. Then go to Advanced > Conditions and use the search tool to include the Event action filter, and then exactly matches TakeAction.


If you have set this segment up correctly as described in our docs here, it will be available for targeting users in the segmentation engine when creating a campaign by selecting Segments > GA segment in the dropdown menu (under Custom segments).