Site icon Jon Loomer Digital

Create a Custom Facebook Event for a Watched YouTube Video in Google Tag Manager

Imagine you have an important YouTube video embedded on a page of your website. If someone watches that video, it will tell you that they are a potential lead. You can create a custom Facebook event to track, optimize, and retarget them with Facebook ads.

The original inspiration for this approach came from this blog post. I made some alterations. Feel free to make your own alterations to fit your needs.

First, know that I use Google Tag Manager to manage my Facebook pixel. One of the reasons I do that is because of the ease of creating custom events like this one.

For more on using Google Tag Manager for creating custom events, check out the following blog posts:

Configure the Video Variables in Google Tag Manager

First, you’ll need to tell Google Tag Manager the actions related to a video you will want to track.

Go into “Variables” on the left.

Click the “Configure” button at the top right for the built-in variables. Then make sure the Video Title, Video Current Time, and Video Percent boxes are all checked (you can select others to fit your needs, too).

Create a Video Trigger

Now, go into Triggers on the left.

Click to create a new one. Name it and click the edit icon at the top right.

Select “YouTube Video” under User Engagement trigger types.

I’ve chosen to capture when the video starts, completes, and is 50% completed.

Again, use what you want here. I found that adding too many captures created errors for short videos.

Click to add JavaScript API support and enable the trigger on “Window Load.” I found that leaving it on the default of DOM Ready resulted in not always firing.

Create a Tag

Go into Tags on the left.

Click to create a new one. Name it and click the edit icon at the top right.

You’ll want to select “Custom HTML.”

Paste the following code within the HTML area (don’t forget the opening and closing SCRIPT tags):


fbq('trackCustom','VideoWatched',{'Title':{{Video Title}},'Video Percent':{{Video Percent}},'Video Time':{{Video Current Time}}})

It will look like this…

Under Advanced Settings, click the box in Tag Sequencing to fire a tag before this one fires. You’ll want to select your Base Pixel Code tag (you should have created this earlier, assuming the pixel is already running on your website).

This assures that your base pixel code will fire before the event code. Otherwise, the event code will not work.

Under Triggering, click the edit icon at the top right.

Select the Video Trigger we created earlier.

Test it with the Facebook Pixel Helper

After all of the steps above are done, submit your changes. Then go to an embedded YouTube video on a page of your website.

To test it, I use the Facebook Pixel Helper Chrome plugin. Watch the video tutorial below that explains how to set this up.

Then check the Facebook Pixel Helper to make sure that the events you created are firing. You should see multiple “VideoWatched” events (assuming you set it up to capture multiple stages).

Here is the final time it fired, showing the video was completed…

Create Custom Conversions for Tracking and Optimization

You’ll want to use these events for both tracking and optimization purposes. Within your Events Manager, click to view your Custom Conversions.

Click to create a new one. Select the VideoWatched custom event.

If you want to get granular, you can create rules to isolate time, percent, or video title parameters.

You can then do any of the following:

Create Website Custom Audiences for Targeting

You can also target people who completed these events. Go into your Audiences page and click to create a new Custom Audience.

Select Website…

Select your pixel. Within the Events drop-down, select the VideoWatched event under the “From Your Events” section.

Refine by “URL/Parameter.”

Just like when you were creating a Custom Conversion, select a parameter and refine accordingly.

You will now be able to target this very specific group.

Your Turn

Have you experimented with custom events for people who watched your embedded YouTube videos? How have you — or how would you use them?

Let me know in the comments below!

Exit mobile version