Question from user:
Hello,
I want to be able to pass the gclid parameter from a cookie stored on my site to a hidden field in a Pardot iFrame.
I can get it to work if the gclid value is in the URL query string. But if it is not – then I cannot get it to track. Here are the two scenarios. I get it to work in scenario A, but not scenario B.
Scenario A
- Visitor hits landing page from ad that contains ?gclid=xx in the URL
- Completes Pardot iframe on page
- Gclid passes through to hidden gclid field in form into Pardot/Salesforce
Scenario B
- Visitor hits landing page from ad that contains ?gclid=xx in the URL
- Visits other pages on the website (no gclid in URL anymore)
- Then visits page containing a Pardot iframe and completes form (no gclid in URL anymore)
- Gclid does not pass through to hidden gclid field in form into Pardot/Salesforce
Anyone have tips on how I can complete this setup? Has anyone had success with this in the past?
Answer from Nabil:
I understand the challenge you’re facing with maintaining the gclid
value for visitors who navigate away from the initial landing page.
The root of the problem in Scenario B is that the Pardot iFrame, which is a separate domain, likely can’t directly read a cookie set by your main site’s domain for security reasons (cross-site scripting prevention), and because the gclid isn’t present in the URL, Pardot’s standard tracking mechanism for it fails.
A modern, robust solution for this involves leveraging several technologies to ensure server-side tracking and data attribution fidelity.
Instead of relying solely on the client-side cookie and the iFrame’s limited ability to read it, you can utilize the Salesforce API, Account Engagement API (which is what Pardot is called now), Google Ads API, and Google Tag Manager (GTM) along with a server-side tagging solution like Stape or Google Cloud Platform (GCP).
The process would work like this: When a visitor arrives on your site in Scenario A, GTM is used to capture the gclid
from the URL and immediately send it to a server-side tracking environment (Stape or GCP).
This server-side environment would also be responsible for setting a unique user_id
or session_id
cookie on your website.
This is a crucial step for maintaining the identity across pages.
When the visitor moves to other pages (Scenario B), the server-side tag is triggered, which passes the associated gclid
and the user_id
to your server.
When the user finally completes the Pardot form in the iFrame, you can use JavaScript on your main page to retrieve the stored gclid from your site’s cookie and dynamically populate the hidden gclid field in the Pardot form before submission.
However, a more reliable solution that bypasses cross-domain issues for the gclid is to use the server-side information you’ve already collected.
The real power comes from the APIs.
You can set up a system where, upon form submission, the Pardot form posts to a handler on your main site that connects the form submission data (including any unique identifiers or the user’s email) with the gclid you stored on your server.
Alternatively, if the Pardot form only creates a Prospect in Account Engagement, you can use the Account Engagement API to update the Prospect record with the gclid you retrieved from your server’s storage, matching by email address or another unique identifier captured in the form.
This server-side approach, often referred to as server-side tagging, allows you to reliably capture crucial attribution data like the gclid even after the user navigates away and the URL parameter is lost.
It also enables more accurate conversion tracking by sending the purchase or lead event directly to Google Ads via the Google Ads API, ensuring you use the enhanced conversion approach with the gclid that you reliably captured on the server.
This setup is highly resilient to browser changes that limit client-side cookie lifetimes or cross-domain tracking, giving you a more complete and accurate picture of your advertising performance.
You’d use the Salesforce API or the Account Engagement API to ensure that all this rich data, including the gclid, eventually makes it into your CRM for proper sales cycle attribution.