# Hubspot event send to google Analytics

**URL:** <https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059>\
**Category:** APIs & Integrations\
**Tags:** events\
**Created:** [July 1, 2019, 4:29am UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059 "2019-07-01T04:29:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zohaib](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zohaib/32/52876_2.png) [@zohaib](https://community.hubspot.com/u/zohaib)\
**Post date:** [July 1, 2019, 4:29am UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/1 "2019-07-01T04:29:04Z")

</div>

Hi @IsaacTakushi dear i am facing another problem in hubspot.How to send Events from hubspot to Google Analytics.. I want to set Form field if google analytics cookie is set.I embeded js code on form and add that form on landing page but it does not set form field(google\_client\_id) when i fill the form on landing page..can you solve this problem.please review my code.

In all Hubspot forms add “GA Client id” as an optional hidden field  
Modify the script tag on all Hubspot forms to set ga\_client\_id if the GA cookie is set

\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/v2.js](https://js.hsforms.net/forms/v2.js)”\>\</script\>  
\<script\>  
function setGaClientId() {  
if ($(‘[name=ga\_client\_id]’)[0]) {  
$(‘[name=ga\_client\_id]’).val(\_((Cookies.get(‘\_ga’) || ‘’).split(‘.’)).takeRight(2).join(‘.’));  
}  
}  
hbspt.forms.create({  
css: ‘’,  
portalId: ‘’,  
formId: ‘’,  
onFormSubmit: setGaClientId  
});  
\</script\>

..Thank you

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [July 2, 2019, 5:07am UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/2 "2019-07-02T05:07:26Z")

</div>

Hi @zohaib ,

While I’m not Isaac, let me help you out here 🙂

I understand that you’re looking to send events from HubSpot to Google Analytics by maniuplating the jQuery and it seems that it is currently not working.

On my end, I tried testing out the code that you provided using a string field and it looks like all is working. Narrowing down to the if condition, it also seems that, there wouldn’t be an issue.

Hence, I believe the issue here is likely due to this line of code:

$(‘[name=ga\_client\_id]’).val(\_((Cookies.get(‘\_ga’) || ‘’).split(‘.’)).takeRight(2).join(‘.’));

Are we able to further check if a value is being returning from this line of code?

Additionally, do you mind sharing with me an example page that has the form embed on it? 🙂

---

<div class="post-metadata">

**Author:** ![zohaib](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zohaib/32/52876_2.png) [@zohaib](https://community.hubspot.com/u/zohaib)\
**Post date:** [July 18, 2019, 10:32am UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/3 "2019-07-18T10:32:31Z")

</div>

@WendyGoh can i add a javascript functions on Forms and on Landing Pages..if yes then please tell me how to add javascript code on forms and landing pages…

Thanks

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [July 22, 2019, 1:19am UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/4 "2019-07-22T01:19:53Z")

</div>

Hi @zohaib,

As per what @IsaacTakushi mentioned here: [Send event from hubspot to google analytics also set form field when google anlaytics cookie is set](https://community.hubspot.com/t5/APIs-Integrations/Send-event-from-hubspot-to-google-analytics-also-set-form-field/m-p/278181/highlight/true#M25430)

_“Marketing Free and Starter forms are rendered in an `iframe` through `js.hsforms.net/forms/shell.js` instead of `js.hsforms.net/forms/v2.js`, so they cannot be manipulated with jQuery or styled with on-page CSS.”_

If your team subscription is any of _Marketing Basic_, _Professional_, or _Enterprise_, you can refer to this documentation here - [on how to unstyled a HubSpot form.](https://knowledge.hubspot.com/articles/kcs_article/forms/how-do-i-style-my-embedded-form)

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [July 2, 2019, 4:50pm UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/5 "2019-07-02T16:50:15Z")

</div>

Thanks for jumping in, @WendyGoh  
 ![16x16_smiley-happy.png.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/2/22d5e40d253def47f5f4ea7f0e3e70be19010689.png)

@zohaib, yesterday, I responded to [your thread from last week](https://community.hubspot.com/t5/APIs-Integrations/Send-event-from-hubspot-to-google-analytics-also-set-form-field/m-p/278181/highlight/true#M25430). Please do not post the same question twice.

---

<div class="post-metadata">

**Author:** ![ralphioooo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ralphioooo/32/48852_2.png) [@ralphioooo](https://community.hubspot.com/u/ralphioooo)\
**Post date:** [September 15, 2020, 9:48pm UTC](https://community.hubspot.com/t/hubspot-event-send-to-google-analytics/15059/6 "2020-09-15T21:48:16Z")

</div>

We have just created a HubSpot APP called Analytics Amplifier that helps you do this + push offline events to Google Analytics when they happen.

Check it out here:

> **[HubSpot Marketplace](https://ecosystem.hubspot.com/marketplace/apps/marketing/analytics-data/google-analytics-amplifier-222008)**
