How to insert Google Analytic Event tracking code in a Guided Marketo Landing Page? | Community
Skip to main content
September 28, 2016
Question

How to insert Google Analytic Event tracking code in a Guided Marketo Landing Page?

  • September 28, 2016
  • 3 replies
  • 3927 views

Hello,

I came across in difficulties for inserting ga event tracking code in a marketo landing page. I have 3 different form & I want to track their activity.

I was trying something like below which seems not working.

<!-- EVENT TRACKING Download --> 

<script src="//app-ab06.marketo.com/js/forms2/js/forms2.min.js"></script>
  <form id="mktoForm_2745"></form>

<script>MktoForms2.loadForm("//app-ab06.marketo.com", "290-DNL-975", 2745, function(form) {
    form.onSuccess(function(values, followUpUrl) {
      ga('send', 'event', 'lead', 'trial', 'window.location.href');
      });
  });
  </script>
  <!-- EVENT TRACKING Download-->

May you kindly provide me the steps to do this.

Thanks

Gyan

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

3 replies

September 28, 2016

Are you not receiving anything in Google Analytics? Have you tried to debug the process line by line? Are you getting any error messages in the console when you do so?

September 28, 2016

I also have a similar issue. What I've found by viewing the page source is that Marketo is converting our Google AdWords tracking code into HTML entities. We also have a guided landing page with a footer section that can be changed and code added that doesn't display as part of the page. The solution should be to allow this without converting to entities. What is happening is that the < > are getting converted to &lt; and &rt; so the script type and other declarations are not working properly.

How can we get tracking code to be inserted into a landing page without having these converted to HTML entities? Marketo is trying to help but instead it is just messing things up by converting these for us. I've treid converting these < > characters to entities before adding the code to the guided landing page but of course that doesn't help - we're not trying to display the code, we're trying to get the code itself into the page html.

Here's what's happening in my page source:

&lt;!-- Google Code for Download Conversion Page A --&gt; &lt;script type="text/javascript"&gt; /* &lt;![CDATA[ */ var google_conversion_id = 877836615; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "nJpfCJet82gQx_LKogM"; var google_remarketing_only = false; /* ]]&gt; */ &lt;/script&gt; &lt;script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"&gt; &lt;/script&gt; &lt;noscript&gt; &lt;div style="display:inline;"&gt; &lt;img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/877836615/?label=nJpfCJet82gQx_LKogM&amp;amp;guid=ON&amp;amp;script=0"/&gt; &lt;/div&gt; &lt;/noscript&gt;

SanfordWhiteman
Level 10
September 28, 2016

If you are adding directly to the template, this should not be happening.  Are you using an interstitial {{lead.token}}?

September 29, 2016

Hello,

My landing page is built in with a guided landing page template.

My issue is How & Where to insert Event tracking code ?

SanfordWhiteman
Level 10
September 29, 2016

You can insert it into the template (which in many cases is where you want it, rather than having to add it manually to all derived LPs).

You can use a Text or Rich Text {{my.token}}. You can use a snippet.

What you can't do -- without causing an unnecessary technical burden -- is use a mktoText variable, because these variables are HTML-encoded upon output. This is similar to the default behavior of custom text fields at the Lead level.

Bottom line: in some contexts, "text" really means "text for output," which means HTML encoding is necessary.

September 29, 2016

Thanks that answered my question. So I can use a Program Token to insert code.

Looking closely at Gyan's question I don't think that's the issue there, I think it probably that has more to do with Google Event Tracking. Sorry for the distraction.

SanfordWhiteman
Level 10
September 29, 2016

Gyan Contact​ please link to a live URL. I can tell you straight away that your code is broken because you aren't using the GA hitCallback option: in production, you'll lose huge swaths of data. Nevertheless you be able to gather some data, not none, provided you test using late-model Firefox or Chrome.