We want to get a lead id and pass It to google analytics when a user fills out a form | Community
Skip to main content
February 1, 2016
Question

We want to get a lead id and pass It to google analytics when a user fills out a form

  • February 1, 2016
  • 1 reply
  • 4269 views

Marketo Analytics – get lead id

We want to get a lead id and pass It to google analytics when a user fills out a form

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

1 reply

Grégoire_Miche2
Level 10
February 1, 2016

Hy Mayank,

You can pass the lead ID to GA as soon as the lead is identified.

It's explained here : Integrating Google Analytics with Marketo

-Greg

February 3, 2016

The blog post doesn't make it very clear how {{lead_id}} is being passed. Do you know if it is possible to simply get the lead id on a successful form submission?

Grégoire_Miche2
Level 10
February 3, 2016

Hi Chris,

Yes it is. Just change the google UA code as described by Courtney:

<script>// <![CDATA[ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'YOUR GOOGLE UA ID HERE', { 'userId': '{{lead.Id}}' }); ga('send', 'pageview'); ga('set', 'dimension1', '{{lead.Id}}'); // ]]></script>

This will register the LeadID as a dimension for filtering in GA

And edit the form code as indicated here: How do you calculate the number of times a form was filled out?  to register events in GA.

-Greg