Has anyone done this? http://developers.marketo.com/blog/send-marketo-form-data-to-google-analytics/
Unfortunately, comments are closed on this. Wondering at the bottom of what code am I supposed to place this? The instructions are pretty ambiguous.
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...
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>
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.