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

2 replies

Ben_Griffith1
Level 3
September 9, 2015

The code Yanir has in their post has a syntax error in it...

plus it has console.log(...), which will also cause errors for most users (those that don't have a console open in their browser, i.e. are using debug tools of some kind).

I would attach the call to the form submit event and use google analytic's hitCallback to do what they are talking about in the blog post: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitCallback.

Casey_Grimes2
Level 10
September 9, 2015

I actually quite dislike the method shown in this blog post, if only because it's really muddying up what events should be, and this sort of data is much more useful as a dimension instead of being separated into an event.

As such, I would do something much simpler. For instance, if you wanted to record Industry as a custom dimension for your reports, turn on user ID tracking, set a custom dimension for industry, and add a Google Analytics call:

<script src="//app-sjg.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_7"></form>

<script>MktoForms2.loadForm("//app-sjg.marketo.com", "986-VBL-924", 7, function (form) {

form.onSuccess(function() {

        var vals = form.vals();

          ga('set', 'dimension1', vals.Industry);

              });

        });

</script>

SanfordWhiteman
Level 10
September 9, 2015

I agree, though the catch with 'set' -- AFAIK -- is that it won't update anything until the next hit. Ben's point about hitCallback is also on-point since otherwise you have a race between GA and the Thank You URL.