What is Facebook Events
Facebook has defined 9 standard events and each has its own parameters. And you can specify your own custom event and dynamically trigger it based on certain action on your page.
Custom event
If standard events do not meet what you need, you can fire custom event on your page like below.
1 2 3 4 5 6 7 8 |
// You can use non-standard event names for audience building when you // do not need to track or optimize for conversions. fbq('trackCustom', 'FrequentShopper', { num_purchases: 8, average_order: 245.24, favorite_category: 'Sporting Goods' }); |
Dynamic event
Dynamic event is event that is triggered based on user action instead of everytime a page is loaded. Below is the javascript that dynamically trigger the standard event with specific info passed to Facebook after a button is clicked.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<button id="checkdetail">Click for Detail</button> // Add Pixel Events to the button's click handler <script type="text/javascript"> $('#checkdetail').click(function() { fbq('track', 'ViewContent', { content_name: 'Really Fast Running Shoes', content_category: 'Apparel & Accessories > Shoes', content_ids: ['1234'], content_type: 'product', value: 4.99, currency: 'USD' }); }); </script> |
This mechanism makes it possible for us to track some interesting events like:
- Certain link is clicked
- A form is filled
- Scroll down the screen to particular %
- Time on page for certain amount of time
- etc (up to your imagination and javascript skill!)
Use Google Tag Manager to manage your Facebook Pixel and Event Code
In this example, I have a page promoting a product and I want to tag users who visit my product page and the ones who click on my product link. Below are the steps I follow to set up my page.
- Create a container in Google Tag Manager.
- Add a HTML tag for Facebook Base Pixel that is triggered for all pageviews.
- Add a HTML tag for dynamic event that captures the link click and fire ViewContent event to Facebook.
- Add the GTM container script to the header of my page.
See my product page HTML below:
From the code above, you may notice that I have the outbound link pointing to “#” because I want to check if my GTM setup is done correctly. I use Facebook Pixel Helper for debugging. See the image below:
You can see 2 events are recorded while ViewContent has warning. The warning is due to that I haven’t set up the Product Catalog on Facebook side. If I do, I can target product ad to the users interested in this product. Facebook Product Ad and Catalog setup will be discussed in another article.
NOTE: In practice, I will have the outbound link goes to other sites. So, my custom event tag may not get a chance to fire after users click the link. To solve this, I need to hold up the site redirection until the tag is fired. You can configure this on GTM trigger rule section of this dynamic event tag
Check Facebook Pixel Stats
The image below shows you that Facebook has received the events fired on this product page (ie. PageView and ViewContent events).
Create Custom Audience
After Facebook receives your events, you can then create the Custom Audience out from these events. For example, I want to create 2 groups with one representing anyone who have ever visited my product page and another one has ever shown interest and click on the product link.
Group 1: Product page visitor
Using Custom Audience include/exclude URL/Event rules, I can specify just the visitors who hasn’t engaged to my product.
Group 2: Users visited the page and engaged product link
After custom audience is defined, you can then create ad targeting them. Congratulation! You have just learnt how to retarget particular segment of your users on Facebook.
Connect with us