ListenLayer allows you to easily capture URL parameters into the data layer. We’ll use this to get the Google Click ID and store it into the browser (so that it persists across pages and sessions). Then we’ll retrieve the click ID as data is collected from critical “calls to action” such as video views, form submissions, eCommerce transactions and chats.
How to Capture & Store the Google Click ID for Offline Conversion Tracking
Every marketer, webmaster and programmer should be capturing the Google Ads Click ID (gclid) to power offline conversion tracking - but so many do it incorrectly or don't do it at all! In this Use Case, we'll explore how easy it is to capture URL parameters using ListenLayer, store them in the browser, and then use them when it's time to collect critical data - tis is the basic process for collecting and capturing gclid with your data, so you can enhance your decision making. Let's dive in!
Ready to get started?
See how easy (and powerful) ListenLayer is by opening an account today or requesting a demo.
Collect GCLID Along With Your Other Data Using ListenLayer
Steps & Code Examples
Step 1: Understand the Overall Process to Capture & Use GCLID
Step 1: Understand the Overall Process to Capture & Use GCLID
Ensure that you understand the overall process of capturing and using the Google Ads Click ID. First, we’ll get the “gclid” parameter from the URL using ListenLayer. Second, we’ll store the value in the user’s browser (allowing it to persist as they browse the website). Next, we’ll retrieve the gclid value from the cookie or local storage and push it back into the data layer during critical actions. Finally, we’ll capture the gclid in a hidden field during a form submission.
Step 2: Capture the GCLID From the URL
Step 2: Capture the GCLID From the URL
Turn on the URL Parameters Listener so that the GCLID will be parsed and pushed into the data layer automatically. Once it’s in the data layer, we can do anything we want with it inside ListenLayer.
Step 3: Capture a Test GCLID
Step 3: Capture a Test GCLID
After publishing your Listener, test it on your website to capture a GCLID. You can see in this screenshot the URL parameters are parsed and pushed into the data layer (which is written to the console).
Step 4: Create a Cookie or Local Storage Key for the Facebook Click ID
Step 4: Create a Cookie or Local Storage Key for the Facebook Click ID
Under Browser Storage Variables, create a new cookie or local storage key that you will use to save the gclid. We cannot simply capture it from the URL and use it, rather we must store it in the browser so that it will persist across pages and sessions from the user.
In the following step we will write a rule to actually save the gclid value into the browser based on a data layer rule.
Step 5: Write a Browser Storage Rule Inside ListenLayer for GCLID
Step 5: Write a Browser Storage Rule Inside ListenLayer for GCLID
ListenLayer uses the data layer to trigger rules you write inside of the platform. Now that we have a cookie or local storage key to save the GCLID into, we need to write the rule that will trigger this action. In this image, you’ll see a simple condition that requires the URL parameters data layer event and the existence of a GCLID. In the following step, we’ll store the GCLID if this condition rule is met.
Step 6: Set the Final Value of the GCLID Cookie
Step 6: Set the Final Value of the GCLID Cookie
When the condition we wrote in the previous step is met, we’ll store the GCLID into the cookie or browser storage key we created. This is done by simply selecting the data layer variable and inserting it to the rule.
Step 7: Test to Ensure that the GCLID is Being Stored
Step 7: Test to Ensure that the GCLID is Being Stored
After publishing your changes, we recommend testing to ensure that the GCLID is actually being stored. Visit your website with the ?gclid=1234 parameter on your URL. Then “Inspect Element,” navigate to Application and find your key.
Step 8: Identify Critical Actions Where You Want to Capture GCLID From the Browser
Step 8: Identify Critical Actions Where You Want to Capture GCLID From the Browser
Consider the critical actions when you’ll want GCLID to be captured with other data. Now that GCLID exists in browser storage, we can easily push it back into the data layer as users interact with our website (always us the data layer, it creates consistency and allows for monitoring). In this case we are going to push GCLID back into the data layer every time a form loads or is submitted on our website. You can use chat, eCommerce, or other critical actions as well.
Step 9: Push the GCLID Back Into the Data Layer
Step 9: Push the GCLID Back Into the Data Layer
When our critical actions occur, we will simply push the GCLID back into the data layer. Here you can see we have a custom data layer variable called user_gclid (we created this inside of ListenLayer) and we are going to push the gclid from the browser storage into this when our rules are met from the previous step.
Once the gclid is back in the data layer, we recommend capturing it with other data such as custom GA4 events. You can also move to the next step and see how to capture it via hidden fields into your CRM.
Step 10: Create a Hidden Field On Our Forms & Set the CSS Class
Step 10: Create a Hidden Field On Our Forms & Set the CSS Class
Create a hidden field on all of your forms – you will use it capture the gclid. ListenLayer will push the Google Ads Click ID into this field based on rules you create and manage in the platform.
Pro Tip: You can write a monitoring rule inside ListenLayer to identify any forms on your website that are missing the hidden field!
Create a unique CSS class for your hidden field. You don’t need to have actual styles for this class, the class is used to identify the field across forms, which is not always required. Some forms systems generate unique fields for each form, making it hard to globally identify a single hidden field unless we unify the with a common identifier.
Here we are putting the string “user_GCLID” into the class field. In the next step we will write a rule to always push the GCLID into any field with this class.
Step 11: Use ListenLayer to Populate the Hidden Field
Step 11: Use ListenLayer to Populate the Hidden Field
Inside of ListenLayer, we can create a rule to populate hidden fields on any form of our website. We’ll write the rule to push the gclid from browser storage into the hidden field based on the css class we created in the previous step. ListenLayer will find any “” element (field) that exists inside an HTML node containing this class.
Critical Screenshots
Ready to Dive In?
See how easy (and powerful) ListenLayer is by opening an account today or requesting a demo.
Search for other use case.
Enter the name use case.