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-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-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-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.
About the Author
Himanshu Sharma
Founder, OptimizeSmart.com
Over 15 years of experience in digital analytics and marketing
Author of four best-selling books on digital analytics and conversion optimization
Nominated for Digital Analytics Association Awards for Excellence
Runs one of the most popular blogs in the world on digital analytics
Consultant to countless small and big businesses over the decade
Free GA4 Mastery Course (30 Days Access) – Certification Upon Completion! (Over 4000 Students)
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.