This guide will walk you through the process of capturing Google’s cookie and saving the client ID into a custom field. By following these steps, you will be able to successfully store the client ID from Google’s cookie in a custom field named “clientid”.


  • In this example we are using a custom field called “clientid“. Be sure to create clientid field.
  • Using GA

Step-by-Step Instructions:

Step 1: Ensure GA Setup

  • Begin by ensuring that Google Analytics has been set up correctly on your website. Navigate to the “Add Scripts” section to verify this.

Step 2: Add the Script

  • To save the client ID from Google’s cookie into the custom field “clientid”, you’ll need to add the following script to the first node of your decision tree and set it to fire on entry:
    function getCookie(name) {
        const value = document.cookie;
        const parts = value.split(`; ${name}=`);
        if (parts.length === 2) return parts.pop().split(';').shift();
    let interval = setInterval(function (){
        if (getCookie('_ga')) {
            LH.setField('clientid', getCookie('_ga').slice(6)); 
    }, 1000);

Add the script to first node and fire on entry as shown below.

This will save clientid from Google’s cookie into the custom field, “clientid”.

Step 3: Do a quick test through your DT and you should see the clientid saved with visitor/lead record.

Pro Tips:

  • Always test your decision tree after adding or modifying scripts to ensure everything functions as expected.
  • Make sure your custom field name matches exactly with the one used in your script.


  • If the client ID is not being saved as expected, check that the Google Analytics setup is correct and the script is properly added to your first node.
  • Verify that the custom field exists and its name is spelled correctly.


Capturing Google’s client ID and saving it in a custom field allows you to track user interactions more effectively. Follow these steps carefully and make sure to validate the process by testing your decision tree.


  • Can I use a different custom field name?
    • Yes, you can use any name for the custom field, just ensure it matches the name used in the script.