Hubspot Chat Google Ads Click ID

Hi,

Im looking for a way to set a contacts google ads click property from ad links through the hubspot chatbot.

I know i can access the gclid from the cookie and I cant find a way of setting it with the chatbot. I would need the contacts email address.

Is there a way to do this?

Thanks

Hi @CHutt5 ,
Thank you for reaching out to the Community!
I’d like to invite some community members who are subject matter experts to join this conversation.

@BrandonWoodruff @DilionSmith @Anton - Would you be able to share any insights on this?

Your expertise would be greatly appreciated.
Best regards,

Victor

the HubSpot chatbot does not natively support writing contact properties like gclid without custom development. However, here’s the technically correct and supported way to make this work:


What You Can Do:

1. Capture gclid using a cookie:

  • HubSpot’s default tracking cookie (_hstc) does not store the gclid by default.

  • You must create a custom script on your website to:

    • Read the gclid from the URL.
    • Store it in a first-party cookie like hubspot_gclid.

2. Pass the gclid to HubSpot via a form or tracking API:

  • You’ll need to ensure the chatbot (conversational bot flow) includes an email capture step.
  • Once you have the email, use one of two options to set the gclid:

Two Technical Paths:

Option A: Use a Hidden Field in a Form

  1. Add a hidden field for gclid in a HubSpot form.
  2. Populate that hidden field via Javascript:

javascript

CopyEdit

document.querySelector(‘input[name=“gclid”]’).value = getCookie(“hubspot_gclid”);

  1. Use a custom bot action that redirects to the form after capturing email.

No API keys needed, but it does require a form submission to update the contact.


Option B: Use the HubSpot Forms API or Contacts API

Once you have the visitor’s email (captured by the chatbot), use a custom JavaScript or server-side function to update their contact record.

Example using HubSpot Forms API (client-side):

hbspt.forms.create({ portalId: ‘YOUR_PORTAL_ID’, formId: ‘YOUR_FORM_ID’, onFormReady: function($form) { $form.find(‘input[name=“email”]’).val(visitorEmail); $form.find(‘input[name=“gclid”]’).val(getCookie(“hubspot_gclid”)); } });

Or use the Contacts API v3 from a backend server:

PATCH /crm/v3/objects/contacts/{contactId} { “properties”: { “gclid”: “AW-xxxx” } }

You’ll need a private app token for this.


What You Can’t Do:

  • You cannot natively update contact properties like gclid from inside a HubSpot chatbot alone.
  • Chatbots do not have access to cookies or URL params.
  • They also don’t support direct property mutation logic without routing through forms or custom API calls.

Recommended Flow:

  1. Visitor clicks ad with ?gclid=…

  2. JavaScript stores gclid in a cookie.

  3. Chatbot collects email → stores it in HubSpot.

  4. You use either:

    • A hidden field form submission, or
    • A background API call
      → to attach the gclid to the contact.

Let me know if this helps, or if you have any other questions!


:check_mark: Was I able to help answer your question? Help the community by marking it as a solution.

Brandon Woodruff
Senior Software Developer @ PearagonStill have questions? Reach out at brandon@pearagon.com

Hi @BrandonWoodruff,

Thanks for your reply.

I understand the prcoess and had started doing it alright, but I’m not sure how the chatbot gets access to the ‘gclid’ cookie in order to save it to the contact? The chatbot doesnt have access to the browser so thats the part im struggling with.

Any help greatly appreciated.

Thanks