Capture Client ID in hidden field from Tag Manager


I’m trying to populate a hidden form field ‘client_id’, made available using Google Tag Manager. So, on Window Loaded I have this variable: 1st Party Cookie string ‘GA1.2.703537689.1505909694’.

How do I grab this bit “703537689.1505909694” and automatically populate a hidden field in a form with id ‘client_id’.

The reason I am doing this is because I need to tie offline conversions (all our sales happen offline) to online lead generation. Once we have a client_ID tied to a customer in our system, we are able to accurately calculate ROI.




Hi Edward,

What’s the full URL look like with the variable in it? Usually, if you just create a hidden field with the exact name of the URL parameter, it’ll pull it in automatically.

See here:


Hello- I am having the same issue and need to obtain the Google Analytics Client ID (see the instruction in Google’s guide step 3)

To Nicholas question- This is not a value that is stored in the URL, but in the Google Analytics Cookie. I tried using the Java Script editor but I believe there are issues as Unbounce defaults the GTM placement after the body, thus the new scripts load before the GA cookie is loaded within GTM. Would really like some help on this!


Hi @jon.gardiner,

If you have an Unbounce form, you can always pause the form submit event. Fill in your hidden field and release the form.

By the time the form is filled out, all of the cookies would have been loaded.



Hi, Could someone give some more info on this topic. I’m also trying to add the ClientID from a cookie to a hidden field. So far i tried to add the clientID to a variable. I get the error: “ga is not defined”.My code is:
<script> var clientID = ga.getAll()[0].get('clientId'); </script>

I also tried it with a setTimeout. Could someone help me in a little more detail. Thanks in advance!


Someone? :slight_smile:


Anyone? :thinking: