![]() ![]() Let’s go to Variables > New > Data Layer Variable and enter the following settings:ĭo the same thing for the rest of the data points you want to use ( video_provider, video_percent, video_title). We need to create a separate Data Layer Variable for each one. In our case, we are going to use the following: If you see all of this as I am, we can continue.ĭata Layer Variables, Custom Event TriggerĮven though we have that video data in the Data Layer, we cannot use it until we create variables for each data point we plan to use. You will see some information about the interaction. You should see a bunch of video events there.Ĭlick one of them and expand the dataLayer.push. Play it, watch for a bit (at least 25% of the video length), and pause. Now head to your website and interact with the HTML5 video player. Save all changes in your GTM container and then click the Preview button in the top-right corner of the GTM interface and enable the preview mode.įirst, in the preview mode, you should see that your Custom HTML tag has fired once the page is loaded. In Google Tag Manager, go to Variables > New > Custom JavaScript and paste the following code: function () Īdd the previously created Window Loaded trigger to this tag. That can be done with the Custom JavaScript variable. Instead of firing the listener on every page, we will be firing it only on those pages where the HTML5 player is actually present. The listener we will use consists of 100+ lines of code, and if you are working with GTM, you should always try to optimize the setup so that it affects the page loading/performance as little as possible. But before we create this tag, we need to create a Custom JavaScript variable. Originally, this solution was created by David Vallejo, but I have added some modifications to make the tracking more convenient with Google Analytics 4. The most important part of this setup is a custom code designed to keep looking for HTML5 video interactions. It will start tracking embedded HTML5 video players + send the data to GA4.Ĭustom JavaScript variable + Auto-event listener If you are in a hurry, I have prepared a GTM container template you can import and configure in your container. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |