SOLVED

Google Analytics and Marketo Integration

Go to solution
Erik_Heldebro2
Level 8

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

Tags (1)
1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

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.

View solution in original post

5 REPLIES 5
Volodymyr_Khomi
Level 1

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

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

JayMurphy
Level 1

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

SanfordWhiteman
Level 10 - Community Moderator

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

 

Trevor_Parsell
Level 6

Hey Erik Heldebro​,

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

SanfordWhiteman
Level 10 - Community Moderator

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.