How do I add a Google Analytics Event tracker in a Vidyard Marketo Form?
Disclaimer: This article is provided for instructional purposes only. Vidyard does not support or guarantee the code. Vidyard also cannot offer support for third-party tools and platforms or technologies such as JavaScript, jQuery or CSS.
Overview
You can use Google Analytics (GA) to not only track the number of people who visit your webpage, but also the actions they take.
For example, you may have a requirement to gather data on Marketo Form submissions that appear within a Vidyard player.
Solution
1. You will first need to copy the GA tracking code related to your instance and paste it into the top of your Marketo form. Directly underneath this code will be another script that adds the functionality to send data into GA. That looks like:
<script type='text/javascript'> function linkClicked () { var playerTitle = window.parent.document.title; ga('send', 'event', 'Vidyard', playerTitle, 'Form Submitted'); } </script>
In the Event, it should end up appearing like this:
2. The next step is to add a reference to the function within the onSubmit section. This should already be part of your code. The line of text you need to add is:
formSubmitted();
Now when your viewers successfully submit the form, an Event will appear in GA that shows:
Category = 'Vidyard'
Action = {Player title}
Label = 'Form Submitted'