Google Analytics and Marketo Integration | Community
Skip to main content
Level 5
Nov 22, 2016 9:05 PM UTC
Solved

Google Analytics and Marketo Integration

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Nov 10, 2017 8:15 PM UTC

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.

5 replies

Volodymyr_Khomi
Level 1
Nov 12, 2018 9:54 AM UTC

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/

Translate
Level 1
Jun 15, 2020 5:30 PM UTC

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

Translate
SanfordWhiteman
Level 10
Jun 15, 2020 7:54 PM UTC

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; });

 

Translate
Trevor_Parsell
Level 5
Nov 10, 2017 2:58 PM UTC

Hey @Erik Heldebro​,

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

Translate
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Nov 10, 2017 8:15 PM UTC

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.

Translate