Google Analytics and Marketo Integration | Community
Skip to main content
Level 5
November 22, 2016
Solved

Google Analytics and Marketo Integration

  • November 22, 2016
  • 2 replies
  • 6655 views

Hi,

Any tips on best practices or personal experiences/challenges to share when integrating Marketo with GA? I have read through this great post on the Champion blog a while ago: Google Analytics and Marketo: Events and Forms and APIs, Oh My!

It's great but there are also quite a few other posts about linking GA Client ID to the Lead ID via JavaScript to a form hidden field.

What would be the most efficient way to do the linking between both IDs? Any cool solutions anybody would want to share that they achieved with the API and Webhooks?

Thanks!

/Erik

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Trevor, any time the {{Lead.Id}} token is available you can use it as the GA User-ID -- you just need to interpolate the token into your JS.

But when it isn't available in JS (i.e. on a non-Marketo page, or before session association is complete) this will not be possible on the client side. You would use the measurement protocol from a webhook to accomplish the same.

2 replies

Trevor_Parsell
Level 5
November 10, 2017

Hey @Erik Heldebro​,

Did you ever find a solution for linking the GA Client ID to the Lead ID via Javascript?

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
November 10, 2017

Trevor, any time the {{Lead.Id}} token is available you can use it as the GA User-ID -- you just need to interpolate the token into your JS.

But when it isn't available in JS (i.e. on a non-Marketo page, or before session association is complete) this will not be possible on the client side. You would use the measurement protocol from a webhook to accomplish the same.

Volodymyr_Khomi
Level 1
November 12, 2018

Maybe it will be helpful - Ultimate Guide to end-to-end Marketo and Google Analytics Integration

linkedin.com/pulse/ultimate-guide-end-to-end-marketo-google-analytics-khomichenko/

Level 1
June 15, 2020

Just FYI - the original post outlining this solution is from Stephan Hamel - stephanehamel.net/assets/docs/MarketoGACheatSheet_SHamel_150824.pdf

SanfordWhiteman
Level 10
June 15, 2020

You don't like the stolen one? 🙂

 

There actually is one significant error (both in the original and in the derivative one). Without using the GA eventCallback and/or hitCallback you will lose hits. 

 

For example, this snippet

 

form.onSuccess(function(values, followUpUrl){ dataLayer.push({ event: "mktoLead", mktoFormId: form.getId() }); return true; });

 

must actually be

form.onSuccess(function(values, followUpUrl){ dataLayer.push({ event: "mktoLead", mktoFormId: form.getId(), eventCallback : function(){ document.location.href = followUpUrl; }, eventTimeout: 2000 }); return false; });