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.

GTM Variables

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).

GTM Variables

Create a Video Trigger

Now, go into Triggers on the left.

GTM Triggers

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

GTM Triggers

Select “YouTube Video” under User Engagement trigger types.

GTM Triggers Video

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

GTM Triggers Video

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.

GTM Triggers Video

Create a Tag

Go into Tags on the left.

GTM Tags

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

GTM Tags

You’ll want to select “Custom HTML.”

GTM Tags

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…

GTM Tags

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).

GTM Tags

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.

GTM Tags

Select the Video Trigger we created earlier.

GTM Tags

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…

Facebook Custom Event Video Watched

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.

Facebook Custom Conversions

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

Facebook Custom Conversions

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

Facebook Custom Conversions

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…

Facebook Website Custom Audience

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

Facebook Website Custom Audience

Refine by “URL/Parameter.”

Facebook Website Custom Audience

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

Facebook Website Custom Audience

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!