Sending Google Analytics Client ID via GTM (Google Tag Manager)
Follow the steps below to create and pass the client ID custom parameter (with user scope) along with the event named ‘get_user_data’ to our GA4 property.
Step-1: Login to your Google Tag Manager account and then click on the ‘Templates‘ link:
Step-2: Click on the ‘Search Gallery‘ button under the ‘Tag Templates’ section:
Step-3: Click on the magnifying glass to display a search box:
Step-4: Type ‘GTAG GET API‘ in the search box and then click on the first search result:
Step-5: Click on the ‘Add to workspace‘ button:
Step-6: Click on the ‘Add‘ button:
You should now see the new tag template listed under the ‘Tag Templates‘ section:
Now, we are going to create a new tag based on this tag template.
Step-7: Click on the ‘Tags‘ link and then click on the ‘New‘ button to create a new tag:
Step-8: Name the new tag ‘Gtag get api‘:
Step-9: Click on the ‘choose a tag type’ button:
Step-10: Scroll down and then click on the custom template ‘GTAG GET API‘:
Step-11: Enter the measurement ID of your GA4 property and then click on the ‘Save‘ button:
Step-12: Click on the ‘Save Tag‘ button, as your tag will not have any firing trigger:
Now, we need to edit the GA4 configuration tag (the Google tag we used to install and enable the GA4 tracking) and add the tag ‘Gtag get API‘ in a tag sequence.
Step-13: Find and edit your Google tag and then click on the ‘Advanced Settings‘ link:
Step-14: Click on ‘Tag Sequencing‘:
Step-15: Click on the checkbox ‘Fire a tag after Google Tag – All Pages fires‘:
Step-16: Click on the ‘Select tag‘ drop-down menu:
Step-17: Click on the ‘Gtag get api‘ tag:
Step-18: Click on the ‘Save‘ button to save your tag:
Step-19: Click on the ‘Triggers‘ link and then click on the ‘New‘ button to create a new trigger.
Step-20: Name the new trigger ‘gtagApiGet‘ and then choose the trigger type to ‘Custom Event‘:
Step-21: Type ‘gtagApiGet‘ in the ‘Event Name’ text box and then click on the ‘Save‘ button:
Step-22: Click on the ‘Variables‘ link and then click on the ‘New‘ button under the ‘User-Defined Variables‘ section:
Step-23: Name the new variable ‘Return Client ID‘ and then set the variable type to ‘Data Layer Variable‘:
Step-24: Type ‘gtagApiResult.client_id‘ in the ‘Data Layer Variable Name’ text box and then click on the ‘Save‘ button:
Step-25: Click on the ‘Tags‘ link and then click on the ‘New‘ button to create a new tag:
Step-26: Name the new tag ‘Send client id to GA4 test property‘ (or whatever best works for you) and then select ‘Google Analytics: GA4 Event‘ as the tag type:
Step-27: Enter your measurement ID:
Step-28: Type ‘get_user_data‘ in the ‘Event Name‘ text box:
Step-29: Click on the ‘User Properties‘ drop-down menu:
Step-30: Click on the ‘Add Row‘ button:
Step-31: Type ‘client_id_custom‘ in the ‘Property Name‘ text box and ‘{{Return Client ID}}.‘ in the ‘Value‘ text box:
Note: Make sure that you add the dot . after the {{Return Client ID}} variable to force GA4 to treat the value of this variable as a string and not a number.
Step-32: Click on the ‘Choose a trigger’ button:
Step-33: Click on ‘gtagApiGet‘ trigger:
Step-34: Click on the ‘Save‘ button to save your new tag:
Step-35: Click on the ‘Preview‘ button to preview your GTM container:
You should now be automatically redirected to a new tab in your web browser.
Step-36: Enter your website address and then click on the ‘Connect‘ button:
You should now be automatically redirected to a new tab in your web browser which shows your website content.
Step-37: Navigate back to your Tag Assistant window and then click on the ‘Continue‘ button:
You should now be able to see the ‘gtagApiGet’ event listed in the event list and the tags ‘Send client id to GA4 test property‘ & ‘Gtag get api‘ listed under the ‘Tags fired’ section:
Step-38: Navigate to the ‘DebugView‘ report of your GA4 property:
Step-39: Find and click on the user property named ‘client_id_custom= ……‘:
Step-40: Find and click on the user property named ‘client_id_custom‘:
You should now be able to see the captured client ID:
Step-41: Navigate back to Google tag assistant window and then close it by clicking on the cross button at the top left-hand side:
Step-42: Click on the ‘Stop debugging’ button:
Step-43: Navigate back to your GTM account and then click on the ‘Submit‘ button to publish your container:
Step-44: Enter your container version name and then click on the ‘Publish‘ button:
That’s how you can create and pass a user scope custom parameter along with an event.
Follow the steps below to create and pass the client ID custom parameter (with user scope) along with the event named ‘get_user_data’ to our GA4 property.
Step-1: Login to your Google Tag Manager account and then click on the ‘Templates‘ link:
Step-2: Click on the ‘Search Gallery‘ button under the ‘Tag Templates’ section:
Step-3: Click on the magnifying glass to display a search box:
Step-4: Type ‘GTAG GET API‘ in the search box and then click on the first search result:
Step-5: Click on the ‘Add to workspace‘ button:
Step-6: Click on the ‘Add‘ button:
You should now see the new tag template listed under the ‘Tag Templates‘ section:
Now, we are going to create a new tag based on this tag template.
Step-7: Click on the ‘Tags‘ link and then click on the ‘New‘ button to create a new tag:
Step-8: Name the new tag ‘Gtag get api‘:
Step-9: Click on the ‘choose a tag type’ button:
Step-10: Scroll down and then click on the custom template ‘GTAG GET API‘:
Step-11: Enter the measurement ID of your GA4 property and then click on the ‘Save‘ button:
Step-12: Click on the ‘Save Tag‘ button, as your tag will not have any firing trigger:
Now, we need to edit the GA4 configuration tag (the Google tag we used to install and enable the GA4 tracking) and add the tag ‘Gtag get API‘ in a tag sequence.
Step-13: Find and edit your Google tag and then click on the ‘Advanced Settings‘ link:
Step-14: Click on ‘Tag Sequencing‘:
Step-15: Click on the checkbox ‘Fire a tag after Google Tag – All Pages fires‘:
Step-16: Click on the ‘Select tag‘ drop-down menu:
Step-17: Click on the ‘Gtag get api‘ tag:
Step-18: Click on the ‘Save‘ button to save your tag:
Step-19: Click on the ‘Triggers‘ link and then click on the ‘New‘ button to create a new trigger.
Step-20: Name the new trigger ‘gtagApiGet‘ and then choose the trigger type to ‘Custom Event‘:
Step-21: Type ‘gtagApiGet‘ in the ‘Event Name’ text box and then click on the ‘Save‘ button:
Step-22: Click on the ‘Variables‘ link and then click on the ‘New‘ button under the ‘User-Defined Variables‘ section:
Step-23: Name the new variable ‘Return Client ID‘ and then set the variable type to ‘Data Layer Variable‘:
Step-24: Type ‘gtagApiResult.client_id‘ in the ‘Data Layer Variable Name’ text box and then click on the ‘Save‘ button:
Step-25: Click on the ‘Tags‘ link and then click on the ‘New‘ button to create a new tag:
Step-26: Name the new tag ‘Send client id to GA4 test property‘ (or whatever best works for you) and then select ‘Google Analytics: GA4 Event‘ as the tag type:
Step-27: Enter your measurement ID:
Step-28: Type ‘get_user_data‘ in the ‘Event Name‘ text box:
Step-29: Click on the ‘User Properties‘ drop-down menu:
Step-30: Click on the ‘Add Row‘ button:
Step-31: Type ‘client_id_custom‘ in the ‘Property Name‘ text box and ‘{{Return Client ID}}.‘ in the ‘Value‘ text box:
Note: Make sure that you add the dot . after the {{Return Client ID}} variable to force GA4 to treat the value of this variable as a string and not a number.
Step-32: Click on the ‘Choose a trigger’ button:
Step-33: Click on ‘gtagApiGet‘ trigger:
Step-34: Click on the ‘Save‘ button to save your new tag:
Step-35: Click on the ‘Preview‘ button to preview your GTM container:
You should now be automatically redirected to a new tab in your web browser.
Step-36: Enter your website address and then click on the ‘Connect‘ button:
You should now be automatically redirected to a new tab in your web browser which shows your website content.
Step-37: Navigate back to your Tag Assistant window and then click on the ‘Continue‘ button:
You should now be able to see the ‘gtagApiGet’ event listed in the event list and the tags ‘Send client id to GA4 test property‘ & ‘Gtag get api‘ listed under the ‘Tags fired’ section:
Step-38: Navigate to the ‘DebugView‘ report of your GA4 property:
Step-39: Find and click on the user property named ‘client_id_custom= ……‘:
Step-40: Find and click on the user property named ‘client_id_custom‘:
You should now be able to see the captured client ID:
Step-41: Navigate back to Google tag assistant window and then close it by clicking on the cross button at the top left-hand side:
Step-42: Click on the ‘Stop debugging’ button:
Step-43: Navigate back to your GTM account and then click on the ‘Submit‘ button to publish your container:
Step-44: Enter your container version name and then click on the ‘Publish‘ button:
That’s how you can create and pass a user scope custom parameter along with an event.
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.