Google Tag Manger (GTM) Cheatsheet
Google Tags, triggers and Tracking form submissions, phone and email clicks, site search.
How to create a Google Tag Manger account
To create a Google Tag Manager (GTM) account, follow these steps:
- Sign in to Google Tag Manager
- Use your Google account to sign in or create a new one if you don’t have it.
- Set Up Your GTM Account
- Click on Create Account.
- Account Name: Enter your business name or something descriptive.
- Country: Choose your country from the dropdown.
- Set Up a Container
- Container Name: Enter the name of the website or app you want to track.
- Target Platform: Select the platform (Web, iOS, Android, AMP) where you’ll use GTM.
- Click Create after filling in the container details.
- Accept GTM Terms of Service
- Review and agree to the terms to proceed.
- Install GTM on Your Website
- You’ll receive code snippets for your site after creating the container.
- Copy and paste the provided codes:
- One goes in the <head> section of your website.
- The other goes immediately after the opening <body> tag.
- Verify Installation
- Use the Preview Mode in GTM or a browser extension like Tag Assistant to confirm your tags are firing correctly.
After installation, you’re ready to start adding tags, triggers, and variables within your new GTM container. Let me know if you’d like more tips on getting started with tags and triggers!
How to Create a Google Tag
Google tag is a required tag to send events from gtm to ga4 The Google tag establishes the data flow from your website to Google Analytics and other destinations you might have set. Create one Google tag per domain and place it on every site that you want to measure.
If you don’t have this tag then events like click tel and mailto will not fire to ga4
The google tag is a connector between GTM and GA4
Create the Google Tag
In GTM,
- Go to tag add new
- Give it a name.. A nice convention for adding this tag is
Google tag configuration - example.com
- Add the tag, from the “sliding draw” hit
google tag
.
Adding the Measurement ID
Measurement ID can be found in GA.
- In google analytics
- Hit the
admin
button in the bottom left - Open
data collection and modifications
- Click
data streams
- Click the
web
tab - Click your data stream (which probably is labeled the same as your website address)
- Find and copy
measurement id
- Add event name
gtm_ga4_data
, this is up to you.
Paste the Measurement ID
Paste the Measurement ID
from GA into the Tag id
field in GTM.
This is what you should have.
Add Trigger
- Add Trigger
- choose
Initialization - All Pages
Click Save
.
Add Google Tag to Google Tag Manger
To add a Google Analytics 4 (GA4) tag to Google Tag Manager (GTM), follow these steps: Step-by-Step Guide:
Sign in to Google Tag Manager:
Go to tagmanager.google.com and sign in with your Google account.
Create a New Tag:
In the Workspace, click on “Tags” in the left-hand menu. Click “New” to create a new tag.
Configure Your GA4 Tag:
Click on “Tag Configuration”. Choose “Google Analytics: GA4 Configuration”.
Enter Your GA4 Measurement ID:
In the Measurement ID field, enter the GA4 Measurement ID. You can find this ID in your Google Analytics 4 property by going to: Admin → Data Streams → Select your web stream → Copy the Measurement ID (it starts with G-).
Set Up Triggering:
Click on “Triggering”. Choose the trigger when the tag should fire. Typically, you’d choose “All Pages” to track across your entire website.
Save Your Tag:
After selecting the trigger, click “Save” to complete the tag setup.
Publish Your Changes:
Once you’ve configured the tag, click “Submit” in the top-right corner of Google Tag Manager. Add a description if necessary, then click “Publish” to push the changes live.
Test Your Tag:
Use the Preview mode in Google Tag Manager to test that the tag is firing correctly on your site. You can also check the Realtime report in your GA4 account to ensure data is being collected properly.
Tracking form submissions with visibility element
** Prerequistes **
- Google Analytics installed on your gtm
- Google tag added to your GTM
Get your Success Message
We are going to use your form success message as the element visibility trigger
. As soon as the browser renders the form success message (which is hidden by default and only visible after the form is submitted) that is when we track it as a conversion.
- You can target the success message by
id
orcss selector
so you want to check the html wrapper of the success msg and copy that.
In my case my success message html is:
1
2
3
4
5
6
<div
class="some-form-class"
id="gform_confirmation_message_1"
>
<p>Thanks for contacting us! We will be in touch with you shortly.</p>
</div>
I’m going to use the id from the above wpforms-confirmation-1109
. When that id is visible on the page, then the Trigger will fire.
Add Trigger
- Select the element
visibility tag
Choose id or css selector
from drop down method selector.
Add Element ID
- Ensure to use the
.
for the.css_selector
, when targeting ids just the text is required. - Paste in the id or css value of the success message html wrapper
- Select Once per page
- Select
minimum percent visible
to be1
- As the message will be a “new” appearence on the screen select
observe dom changes
Use class ID for best practice
using css class can have performance hit.
Confine test to Specific page
Set trigger to fire on some visibility events
.
Page URL equals https://example.com/your-page
.
Preview Changes
- Enter URL where form is, test the form submission and see if the
element visibility
event was Triggered.
Attach the trigger to tag
Create a Tag
- Add New Tag
- Call it same name as the trigger
Add the following to create your tag
- Google analytics
- GA4
- Add
measurement id
- Add event name of
generate_lead
When the event is sent, Google Tag Manager also sends the page url
which is important for working out which page form was submitted on you can see these pages in pages and screens
and then filter by key event
Please Note: the form submission event must be marked as a key event in Google Analytics (GA).
Select Trigger
- Select your visibility Trigger you created earlier
- Save
Can I have Multiple Triggers?
If you have multiple forms you can have multiple triggers using a unique id for each form. Just keep adding more triggers. In Google analytics you can see which form was submitted.
Preview Test
- Hit Preview
- Fillout your form
- In tag manager debugger window
- Hit element visibility event in sidebar
- Check your form submission tag was fired.
Submit your changes.
If everything worked in the preview submit your changes.
More Info
Tracking Phone clicks
Add a Google Tag
This only needs to be done once in your gtm and you can reuse it for all events The Google tag establishes the data flow from your website to Google Analytics and other destinations
Add Click Variables
This only needs to be done once in your gtm and you can reuse it for all click events
Go to Variables
- Click
configure
in top right - Scroll down to
clicks
To ensure we have the required Variables enabled in GTM we need to add the ones we need for the click tel
.
- For tracking phone clicks, we just need to add the
Click URL
from the “click” section of variables. - Scroll down and enable the
Click URL
by checking the check box. - Then click Add
Add Triggers
- Call it
phone_click
- Click -
just links
. Some link clicks
.CLICK URL
containstel:
- Save
Create a Phone click Tag
- Go to
Tags
- Click
New
tag - Call it
phone_click
- Tag configuration
- Choose
Google Analytics
- Choose
Google Analytics: GA4 Event
- Add
GA4 Measurement ID
- event name
generate_lead
Your tag should be able to locate the google tag you created earlier. If your tag cannot find the google tag. then your missing your google tag and you still need to add it. Creating a google tag
Get Measurement ID
Now you need to go to Google Analytics instead of tag manager. Frustrating? Absolutely! So open a new tab and start loading up the Google Analytics account for the client your working for.
- In Admin, under
Data collection and modification
, clickData streams
. - Select the Web tab.
- Click the
web data stream
. - Find the
Measurement ID
in the first row of the stream details.
Now you need to back to tag manager and add in the measurement id.
Add Event Name
phone_click
Add Trigger To Tag
- Choose your
phone
trigger you created earlier - Hit save
Preview
- hit preview
- add url
View the data sent from GTM in GA4
- Login to Google Analytics
- Click Engagement
- Click Events
- if users have interacted with your site by clicking the click tel then you will see that event in GA4
More resources
Where to find the Google Tag Manger Integration code
Prerequisites
You have a google tag manager account
Go to tag manager
Locate your ‘container’
The thing you want to locate is refered to as a ‘container’ which is a bit confusing. Anyhow this is what your looking for.
tagmanager container
Get the code
- Hit the cog wheel
- Then hit the install tag manager option.
install tag manager code
Copy the code
Now you have the code appear. Ready to be copied to your website.
Cant find your container?
Ensure your logged in as the correct google user
Track site search with GTM
When your site does not use the q=
query parameter.
Instead you have something like this example.com/index/search/contact
then use following config in GTM
Go To Variables
- create new variable called
site search term
- select
regex table
as variable type - select
page path
as the input variable - click
add row
- for the pattern
^/index/search/(.*)
for the output$1
this pattern will store the value of the search in in the variable$1
- save the variable.
Create a tag
to send search term to analytics
- select tag config
- ga4 event as the tag type
- add measurement id
- add event name
view_search_results
Add event parameter to tag
- add parameter named
search_term
- for the value select the variable you created earlier
- now scroll down and select triggering
add the trigger
- add trigger called
search results
- add page view which fires on some views.
- select page path
- select condition to
matches regex
- add
^/index/search/(.*)
as the value (or whatever values your search result page uses)
The trigger ensures the event only fires on the search results page
GTM Access
Dont know who the owner of a Google Tag Manger (GTM) account is?
** Audit User Permissions: ** Check the users listed on the Google Analytics (GA) account. The creator of the Google Tag Manger (GTM) is probably also listed as an admin on the Google Analytics (GA) account.
How to share access to Google Tag Manger (GTM)
Login at https://tagmanager.google.com
Go to Admin
See screenshot https://share.cleanshot.com/vt8W9sDv
Go to User Management
See screenshot https://share.cleanshot.com/m6zyCXT5
Add user from the forthcoming slideout screen
Set Permissions
- Check the Admin box under both Account Permissions and Container Permissions.
- For Container Permissions, select Publish along with Read, Edit, and Approve to provide full access at the container level.
Add custom html script
Add a javascript snippet to your website to integrate a third party functionality.
Tags
- Hit new
- Configure tag
- Create
custom html
tag calledhotjar, wildjar, linkedin or facebook
code - Paste script including script tags
Triggers
- Create trigger to fire on
all pages
- Preview to check the tag is firing
test
- In preview you should see tag firing
Why store scripts in Google Tag Manger?
- No developer required
- If you rebuild your site, Just add the 1 Google Tag Manger Script back into your site and thats it. ALl your 3rd party integrations have been carried across to your new site.
- no login to website required
GTM trigger types
Page URL
In Google Tag Manager (GTM), the “Page URL” trigger is used to fire tags based on the URL of the page being viewed.
Click URL
In Google Tag Manager (GTM), the “Click URL” trigger is used to fire tags based on the URL of a clicked link or element.
you can combine
page url
andclick url
trigger to only track link clicks on specific page
Click Classes
In Google Tag Manager (GTM), the “Click Classes” trigger is used to fire tags based on the CSS classes of the clicked element.
Click Element
In Google Tag Manager (GTM), the “Click Element” trigger is used to fire tags based on interactions with specific elements on your webpage. This trigger allows for a high level of specificity, enabling you to track clicks on virtually any HTML element. Here’s how to use and set up a Click Element trigger:
Click Text
In Google Tag Manager (GTM), the “Click Text” trigger is used to fire tags based on the text content of the clicked element. This is useful for tracking interactions with elements that have specific text, such as buttons, links, or other clickable elements with identifiable text.
GTM Containers
What are containers?
Google Tag Manager (GTM) containers are essentially the workspaces that hold all the tracking codes (tags), triggers, variables, and other configurations for a specific website or app. When you create a container, you’re setting up a place to manage all the tags for that particular site or app in one central location. Here’s a more detailed breakdown of what GTM containers are and what they do: Key Components of a GTM Container:
Tags: Tags are snippets of code (usually JavaScript) that send information to third-party services like Google Analytics, Google Ads, Facebook Pixel, and other marketing/analytics platforms. A container can hold multiple tags for various services. Triggers: Triggers define when and where the tags are fired. For example, a trigger might be set to fire a tag on all page views, on specific button clicks, or after a form submission. Variables: Variables are dynamic values that GTM uses to pass information between tags and triggers. For example, a variable could be the value of a page URL, a click text, or a custom data layer value. Folders: GTM also allows you to organize tags, triggers, and variables into folders to keep things structured, especially when managing a lot of elements.
How Containers Work:
One Container per Website/App: Each website or app typically has its own container. Once you create a container, you install it on your website or app by adding the GTM container code snippet to your site’s HTML or through a platform-specific integration. Centralized Management: The benefit of a container is that it centralizes the management of all your tracking codes. Instead of editing a website’s code every time you want to add or change a tag, you can simply update the tags within GTM, making the process much faster and less error-prone.
Benefits of Using GTM Containers:
Faster Deployment: You can add, edit, or remove tracking tags without needing to modify the website’s source code. Flexibility: Containers support tags from many third-party vendors, not just Google services, making it easier to manage multiple marketing and analytics tools. Version Control: Each time you make changes to a container and publish them, GTM creates a version history, allowing you to revert to an earlier version if needed.
In summary, a GTM container acts as a container for all the tracking and analytics scripts on your website or app, offering centralized control and flexibility.
What permissions are needed to create containers in GTM?
To create containers in Google Tag Manager (GTM), you need specific permissions at the account or container level. GTM has different roles, and the permissions granted depend on the role you are assigned.
Here’s a breakdown:
Account Permissions:
Admin: Full control, including creating containers, managing permissions, and all account-level actions. User: Limited to container-level actions unless additional container permissions are granted.
Container Permissions:
Read: View container configuration but cannot edit or create anything. Edit: Modify tags, triggers, and variables but cannot publish changes. Approve: Approve changes made by others but cannot publish. Publish: Make changes live by publishing them.
To create a new container:
You need to have Admin access at the account level, as container creation is an account-level action. If you’re unsure of your permissions, you can check by going to Admin > User Management in GTM. There, you’ll see your role and what actions you’re allowed to perform.
How to update user permissions in GTM
To change a user’s permission in Google Tag Manager (GTM), you’ll need to have Admin access to the GTM account. Here’s how you can do it: Steps to Change User Permissions in GTM:
Log in to Google Tag Manager: Go to Google Tag Manager and log in with your Google account.
Select the GTM Account: If you have access to multiple GTM accounts, select the one where you want to change the user’s permissions.
Go to the Admin Panel:
In the top navigation bar, click on the Admin button. This will bring you to the Account and Container settings.
Manage User Permissions:
Under the Account section, click on User Management. This will show you a list of users who have access to the account and/or containers.
Select the User:
In the user list, find the user whose permissions you want to change. Click on their name to open their permission settings.
Change Account Permissions (Optional):
If you want to change their Account-level permissions, you can select: Admin: Full control, including the ability to add/remove users and create/delete containers. User: Limited access, restricted to container-specific permissions.
Change Container Permissions:
You can also modify their permissions for specific containers within the account. Under Container Permissions, you will see a dropdown next to each container. You can set it to:
No Access: The user has no access to this container. Read: View-only access to the container. Edit: Ability to modify tags, triggers, and variables, but not publish changes. Approve: Ability to approve changes made by others but not publish them. Publish: Full control to edit, approve, and publish changes.
Save Changes: After adjusting the permissions, click the Save button to apply the changes.
Notes:
You can assign different permissions for different containers. For example, a user can have Publish rights on one container and only Read access on another. You can also add new users and set their permissions in the User Management section.
By following these steps, you’ll be able to manage and adjust user permissions within your GTM account.