Google Tag Manager Button Click Tracking
Universal Analytics events
Google Tag Manager uses trigger configurations to fire tags in response to events. This article explains how to use Tag Manager to set up Universal Analytics event tags that are triggered in response to clicks on links, clicks on other types of elements, at timed intervals, and when a forms are submitted.
This article describes how to configure Tag Manager to create triggers that listen for certain types of events that are expected to occur on a web page. For more precise control of your trigger functionality, set up your code to use triggers based on events pushed to the data layer.
Link clicks
There are two common methods shown here for how to send click event information to Google Analytics:
- Use a separate trigger and tag for each type of link.
- Use a single tag with a regular expression to handle all click data.
For these examples, we will assume that a web page contains a navigation menu with these link names and URLs:
Buy | https://example.com/buy.html |
About | https://example.com/about.html |
Contact | https://example.com/contact.html |
Use separate triggers and tags to measure clicks
This method requires the creation of three triggers and three tags - one trigger/tag pair for each item in the table above:
- Add a Google Analytics pageview tag if one does not already exist. This tag must fire on all pages.
- Enable Tag Manager to capture clicked URL data:
- Click Variables.
- In the Built-In Variables section, click Configure.
- Enable the checkbox for Click URL.
- Create triggers that listen for link clicks for buy.html, contact.html, and about.html:
- Click Triggers New.
- Click Trigger Configuration Click - Just Links.
- Add these settings to the trigger configuration:
- Repeat these steps for "contact.html" and "about.html"
- Create three new Google Analytics tags to measure clicks for each page:
- Click Tags New.
- Click Tag Configuration Google Analytics - Universal Analytics.
- Set Track Type to Event.
- Enter Event Tracking Parameters:
- Category: Nav
- Action: Select
- Label: Buy
NOTE: The Label value should correspond to the particular link being clicked (e.g. "Buy" for buy.html, "Contact" for contact.html, and "About" for about.html). - Tag Name: UA - Event - Buy Link
- Non-Interaction Hit: False
- Google Analytics Settings: Select an existing Google Analytics Settings variable, or create a new one.
- Click Triggering and select the trigger that you created in step 3, titled "Trigger - Buy Clicks".
- Give the tag a name and save the tag configuration.
- Repeat these steps to create tags for the Contact and About links. Remember to set the Label value according to the name of the page, e.g. "Buy" for buy.html, "Contact" for contact.html, and "About" for about.html
- Publish the container.
Use a single tag to measure clicks
You can simplify your container with a single trigger that uses a regular expression to fire on the correct pages, and a single tag that uses a Tag Manager variable for the Label field:
- Add a Google Analytics pageview tag if one does not already exist. This tag must fire on all pages.
- Enable Tag Manager to capture clicked URL values:
- Click Variables.
- In the Built-In Variables section, click Configure.
- Select the Click URL built-in variable.
- Create a single trigger to handle link clicks for each item in the table above:
- Click Triggers New.
- Click Trigger Configuration Click - Just Links
- Configure the trigger with these settings:
- Name the trigger "Trigger - Nav Clicks" and save.
- Create a single Tag to handle all clicks:
- Click Tags New.
- Click Tag Configuration Google Analytics - Universal Analytics.
- Set Track Type to Event.
- Complete the Event Tracking Parameters:
- Category: Nav
- Action: Select
- Label: {{Click URL}}
- Click Triggering and select the trigger that you created in step 3, titled "Trigger - Nav Clicks".
- Save the tag.
- Publish the container.
Clicks on any element
Use this technique to measure clicks on elements other than links. This includes clicks on images, <div>
elements, or any other item on the page accessible by the DOM. For this example, each image has a class
attribute value of gallery
and a unique ID attribute value for each image:
<a href="ggb.jpg" class="gallery" id="Golden_Gate_Bridge">
<a href="tm.jpg" class="gallery" id="Taj_Mahal">
In this example, we use these attributes to configure a trigger that fires on image tags with class="gallery"
, and use that trigger to fire a tag that sends the respective ID values (e.g. Golden_Gate_Bridge
, Taj_Mahal
) to Google Analytics:
- Add a Google Analytics pageview tag if one does not already exist. This tag must fire on all pages.
- Enable Tag Manager to capture clicked class and ID values:
- Click Variables.
- In the Built-In Variables section, click Configure.
- Select the Click Classes and Click ID built-in variables.
- Create a new trigger that fires when a link has a class attribute value of
gallery
:- Click Triggers New.
- Click Trigger Configuration Click - All Elements .
- Enable this trigger when all of these conditions are true: Page URL contains
/
- This trigger fires on: Some Clicks Click Classes contains
gallery
. - Save the trigger and name it "Trigger - Gallery Image Click" when prompted.
- Create a tag to capture the ID attribute values for a clicked image:
- Click Tags New.
- Click Tag Configuration Universal Analytics.
- Set Track Type to Event.
- Complete the Event Tracking Parameters:
- Category: Image Gallery
- Action: Click
- Label: {{Click ID}}
Note: the curly braces are used in text fields and custom code to replace a valid Tag Manager variable name with the relevant value retrieved from the event. - Non-Interaction Hit: False
- Google Analytics Settings: Select an existing Google Analytics Settings variable, or create a new one if necessary.
- Click Triggering and select the trigger that you created in step 3, titled "Trigger - Gallery Image Click".
- Save the tag as "GA - Event Tag - Gallery Image Click".
- Publish the container.
Timed intervals
Implementation of timed interval tags may influence bounce rate reports such that the numbers may appear lower than expected.
Measure timed intervals when you need to understand time on page when no events are triggered. This might include users who read text or play video on the page. Additionally, given that Google Analytics sessions timeout after 30 minutes by default, you may wish to implement a 'keepalive event' to ensure that an activity is sent every 25 minutes.
To configure a tag that measures timed intervals:
- Add a basic Google Analytics pageview tag if one does not already exist. This tag must fire on all pages.
- Create a Timer Trigger:
- Click Triggers New.
- Click Trigger Configuration Timer.
- Add these settings to the trigger configuration:
- Save the Trigger as "Trigger - Session Timer"
- Create a session timer tag:
- Click Tags New.
- Click Tag Configuration Universal Analytics and add these settings to the tag configuration:
- Track type: Timing
- User Timing Tracking Parameters: Leave blank or add values as desired for your reports.
- Click Triggering and select the trigger that you created in step 2, titled "Trigger - Session Timer".
- Publish the container.
Form submits
This technique will cause a tag to fire every time a form on a web page is submitted. This example assumes the <form>
HTML tag contains an ID attribute with a value of "contact_us
":
<form action="/example" method="POST" id="contact_us">
We can use this ID to create a trigger that will listen for when this form is submitted:
- Add a basic Google Analytics pageview tag if one does not already exist. This tag must fire on all pages.
- Enable Tag Manager to capture form IDs:
- Click Variables.
- Click Configure in the Built-In Variables section.
- Select the Form ID built-in variable.
- Create a form submit trigger:
- Create the tag to measure form submits:
- Click Tags New.
- Click Tag Configuration Universal Analytics.
- Set Track Type to Event.
- Fill in the Event Tracking Parameters:
- Category: Forms
- Action: Submit
- Label: Lead Gen - {{Form ID}}
Note: the curly braces are used in text fields and custom code to replace a valid Tag Manager variable name with the relevant value retrieved from the event.
- Non-Interaction Hit: False
- Google Analytics Settings: Select an existing Google Analytics Settings variable, or create a new one.
- Click Triggering and select the trigger that you created in step 3, titled "Trigger - My Form Submits".
- Save the tag as "GA - Event Tag - Form Submits".
- Publish the container.
Related resources
- Deploy Google Analytics with Tag Manager
- Google Analytics custom dimensions
- Google Analytics Content Groups
- Measurement with user IDs
- Google Analytics ecommerce
- Measure user activity across domains
- Google Analytics dynamic remarketing
- Google Analytics help center: About Google Analytics events
Was this helpful?
How can we improve it?
Google Tag Manager Button Click Tracking
Source: https://support.google.com/tagmanager/answer/6106716?hl=en
Posted by: higginbothamfacking.blogspot.com
0 Response to "Google Tag Manager Button Click Tracking"
Post a Comment