Mobile app version of vmapp.org
Login or Join
Cooney921

: How can I track (funnel) if someone from a particular banner campaign watched our demo video? I'm setting up a banner on a website with the caption View our Demo Video. The Banner has the

@Cooney921

Posted in: #AnalyticsApi #EventTracking #GoalTracking #Youtube

I'm setting up a banner on a website with the caption View our Demo Video. The Banner has the UTM campaign tracking code setup and working.

On our website I've got an embedded iFrame YouTube video that triggers two events: one if it is played, and one if it reaches the end.

What I'm trying to figure out now is if there's a way to create a Funnel Goal that sees if someone came in from the banner, did they proceed to watch the video?

This is a snippet of the code I used to capture the YouTube event

if (event.data == YT.PlayerState.PLAYING) {
ga('send', 'event', 'YouTube', 'Started', 'Promo from Main Page');
}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cooney921

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ravi8258870

Yesterday while reading and thinking about this is dawned on:

utm_source, utm_campaign, and utm_medium all get passed through as PHP variables. I'm no coder so this is very, very sloppy in execution. I might touch it up when I have the time since it would be hard to add additional campaigns if we were to run more then one banner at a time.

Somewhere towards the top of the page with the video I added:

<!-- checks the utm_source -->
<?php

if(isset($_GET['utm_source'])) {
$utm_source = $_GET['utm_source'];
} else {
$utm_source = 'zilch';
}

?>


Then I edited the YouTube event handling to add an If/Then Statement which is where it gets even messier.

function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
if (utm_source == 'zilch') {
ga('send', 'event', 'YouTube', 'Started', 'Promo from Main Page');
}
else if (utm_source == 'EXAMPLE') {
ga('send', 'event', 'YouTube', 'Started', 'Promo from Main Page via EXAMPLE');
}
else {
ga('send', 'event', 'YouTube', 'Started', 'Promo from Main Page');
}
}
if (event.data == YT.PlayerState.ENDED) {
if (utm_source == 'zilch') {
ga('send', 'event', 'YouTube', 'Finished', 'Promo from Main Page');
}
else if (utm_source == 'EXAMPLE') {
ga('send', 'event', 'YouTube', 'Finished', 'Promo from Main Page via EXAMPLE');
}
else {
ga('send', 'event', 'YouTube', 'Finished', 'Promo from Main Page');
}
}
}


It's not the prettiest since this is the first real javascript I've ever worked with but it does function exactly how I need it to.

Ideally within the javascript it should check if utm_source is set to a value and if so append that value to the ga event link. If not then leave the ga event link as it is. If anyone knows how to do that feel free to leave a comment or additional answer.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme