Phase 1:
In Google Tag Manager, go to Variables > New > Custom JavaScript and paste the following code:

And Name this variable as “cjs – is HTML5 Video on a page”.

Phase 2:
Then go to Triggers > New:
In Trigger Configuration
Trigger Type => “Page View – Window Loaded”
This trigger fires on “Some Window Loaded Event”
Fire this trigger when an Event occurs and all of these conditions are true:
“cjs – is HTML5 Video on a page” equals “true”
And Name this trigger as “Pageview – HTML5 Video Player is Present”.

Phase 3:
Tags > New
Select “Custom HTML”
then paste the following code:

And Name this tag as “cHTML – HTML5 Video Listener”.

Add Google Tag Manager code into & .

This setting will help the browser to set variables about the current website that contains any video tag after the window load successfully. if true, the video listener script will apply to each video tag.

If the concept is fine, we are now to add 4 variables to pushing to GA Event.

We go to Variables > New:
Using Data Layer Variable, and name it video_status, folder name can use the same name, then press save.
Using Data Layer Variable, and name it video_provider, folder name can use the same name, then press save.
Using Data Layer Variable, and name it video_percent, folder name can use the same name, then press save.
Using Data Layer Variable, and name it video_title, folder name can use the same name, then press save.

After that, let go Triggers > New.
Name it as “Custom – Video Interaction”
We are choosing the trigger type “Custom Event”
Set Event name to “video”
this trigger fire on “All Custom Events” is fine.

If you added the trigger item. let do the last setting.

go to Tags > New
and choosing GA4 event
Name it as “GA4 event – video”
Configuration Tag is “None – Manually Set ID”
(Go to Google Analytics > Admin > Data Streams > Web > copy the measurement id) if there is empty please add a new stream for it.
Event Name is “video_{{video_status}}”
Add 3 more item to Event Parameters
Parameter Name Value
video_provider {{video_provider}}
video_percent {{video_percent}}
video_title {{video_title}}
Apply Triggering for this tag “Custom – Video Interaction”
Done.

Reference Link Here Analytics mania

發佈留言