Please note: our integrations are not available on the Free plan, to gain access you will need to upgrade to any of our paid plans!
With the Google Analytics integration, the Vidalytics player can send video watch data to your Google Analytics account. This can then be used to track video events and to create audiences for Google Ads.
Connecting Google Analytics
First, you'll need to install the appropriate tracking code onto the page where the player is embedded.
If you’re using Google Analytics via Google Tag Manager:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
Elements to modify:
GTM-XXXXXXX should match your container ID
For more information about installing the Google Tag Manager snippet, visit the official Quick Start Guide.
If you’re using Universal Analytics (gtag.js):
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
Elements to modify:
UA-XXXXXXXX-X should match your Google Analytics property ID
Please follow the official Universal Analytics (gtag.js) article for more details.
New Google Analytics 4 implementation
If you have set your Google Analytics 4 from scratch, you can follow the same instructions above, and just replace UA-XXXXXXXX-X property ID with your new GTM-XXXXXXX from Google Analytics 4 in the tracking code.
If you're using Universal Analytics (gtag.js) and want to also send the video watch data to Google Analytics 4, you can add just one line to the previous code snippet, like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
// add this line if you want to also send data to the new Google Analytics 4
gtag('config', 'GTM-XXXXXXX');
</script>
You can also add Google Analytics 4 to your existing Universal Analytics using the steps below, without having to touch any code:
Enable Google Analytics integration
Enable Google Analytics integration in your Vidalytics account and choose what player events you would like to track:
Play
Pause
Pause Percentage
Watched Percent (i.e. 25%, 50%, 75%, 99% etc.)
Play Gate Submit
IMPORTANT: don’t forget to republish your video(s) after enabling your GA / GTM integration 🙂
Configure Google Tag Manager
If you’re not using Google Tag Manager, just skip this step.
As Google Tag Manager is a tag management solution that acts as a middleman between your website and marketing/analytics tools (Google Analytics is just one of them), you’ll have to do some additional setup to pass the video watch data to Google Analytics.
User-defined variables
You’ll need to create two user-defined variables that will access the data from the player:
videoTitle - it’s needed for every player event
value - it’s needed only if you want to track Pause Percentage event
To create a user-defined variable, go to Variables > User-Defined Variables > New, choose a name for your variable and set a variable type as a Data Layer Variable:
Data Layer Variable Name should be set as a videoTitle (as it's the name of the key that the player sends to Google Tag Manager).
Triggers
You’ll need to create a custom event trigger for each player event you want to use in Google Analytics:
To create a trigger, go to Triggers > New. Choose Custom Event as a trigger type and enter the following settings (these settings will be pretty similar for all the triggers):
Tags
Finally, you'll need to create tags that will send the watch data to Google Analytics when the triggers are fired:
To create a tag, go to Tags > New. Select tag type as Google Analytics: GA4 Event and enter the following settings:
For Pause Percentage event you'll also need to pass an additional value parameter, like this:
How to test the player events in Google Tag Manager
To make sure that the events are sending properly from the player to Google Tag Manager, you can use a Preview Mode. Click the Preview button and then enter your website's URL:
Play the video and keep looking for the Data Layer events in the left sidebar. They should look like this:
IMPORTANT: Don't forget to register custom definitions in Google Analytics 4
This applies to any event parameter that you send to Google Analytics 4. If you want to use them in things like Funnel exploration and see them in standard reports etc., you must register custom parameters in Google Analytics 4.
To do that, go to Configure > Custom Definitions. Since the player sends 2 custom parameters (videoTitle and value), you'll need to register them both:
Click the Create Custom Dimensions button and then enter:
Dimension name. You can enter whatever you want. This is just how the dimension will be displayed in your reports.
Scope. Since you want to apply this parameter only to one event (and not to all events), you need to select Event
Event parameter. You have to enter the parameter name precisely as you entered it in the Google Tag Manager tag. Don’t worry if the autocomplete does not show your parameter yet. Just enter it and save the dimension
IMPORTANT. If you want to also send the video watch data from Google Tag Manager to Universal Analytics, you'll have to create an additional user-defined variable:
As Google Analytics 4 tags won't pass the data to Universal Analytics by default, you'll need to create separate tags for this:
Please use these settings while creating a tag for Universal Analytics:
Checking Your Data in Google Analytics 4
To see the events in Google Analytics 4 immediately, go to Reports > Realtime:
You can also check the player events in Configure > Events table (please note that it may take up to 24 hours before the new events will appear in that table):
To check the player events in Debug Mode, go to Configure > DebugView:
Checking Your Data in Universal Analytics
Inside Universal Analytics, you can see events immediately here:
And the totals report here (it takes one day to update the Total Events report):
To see more details, click on the "Video" category.
Track Goals in Universal Analytics Based on Video Watch Time
To track goals inside of GA based on the watch data you're passing via the code above, follow these steps:
Set your Goal as 'Custom'.
Add a title and set the type as 'Event'.
The goal details will depend on what you're wanting to track with this code.
Category - video
Action - this could be 'Play' or 'Pause' or 'Pause Percentage' or "(number)% watched" e.g.: "10% watched" or "30% watched"
Label - The title of your video
Value - This is not required for play percentage, but you will need to add it if you're wanting to track 'Pause Percentage' e.g.: 35 (i.e. pause at 35%)
Save your goal and you're ready to go!