Tracking Button Clicks

How to add CAPI Facebook Tracking an add to cart button click using GTM and Deviate Tracking

Learn how to implement or troubleshoot Deviate Tracking’s Facebook CAPI Tag in Google Tag Manager to track Add To Cart buttons on a website. The setup is as simple as the usual Google Tag Manager Trigger & Tag setup with Deviate Tracking’s Facebook CAPI Tag template.

Before starting this tutorial, make sure that Google Tag Manager (GTM) is installed.

Adding in variables per tag/trigger is a redundant task and easy mistakes can be made, so it’s best to configure the required Deviate Tracking variables beforehand. This will help avoid easy mistakes and save time in the future. Setup and preconfigure the required Deviate Tracking Variables with this tutorial.

Firstly, within GTM, create a Trigger so that the Deviate Tracking Tag fires accordingly on the website. Within the GTM Workspace, find the Triggers option in the left-hand side menu. Click ‘New’ to start configuring the Trigger.

Next, click the empty Trigger Configuration box and select the ClickAll Elements Trigger Type in the Choose Trigger Type menu options. Select Some Clicks for this Trigger to fire. The next step will be to specify which clicks will cause this Trigger to fire a Tag.


If the Trigger should fire the Tag on all Add to Cart buttons, then a variable must be used to specify this. Three dropdown options should have appeared below. In the first dropdown, choose Built-In Variable and select “Click Text.” Create a filter by choosing Matches RegEx (ignore case) in the second dropdown option. The last dropdown option should contain the text that the Add To Cart button contains. Examples may include Add to Cart, Buy Now, etc.