How to Add the Facebook Pixel Event Code to Your Joomla! Website

Insert the Facebook Pixel on Your Joomla Website

Facebook pixel event code makes it easier to track your visitor's behavior and track the results you get from your Facebook ad campaigns. In this blog, I will show you how you find them and add them to your Joomla! website.

What is the Facebook pixel and why do you need to add it to your website?

The Facebook pixel allows you to:

  • create powerful audiences for ad targeting
  • run dynamic ads
  • track conversions
  • optimize for conversions

The first step is to install the Facebook Pixel base code. So if you haven't done it yet start with that step. I explained what it is and how you add it to your Joomla website in the previous blog post How to Add the Facebook Pixel Base Code to Your Joomla! Website

Let’s get started with locating where you can find the Facebook pixel event code

1. Login to business.facebook.com

2. Choose the Facebook Ads Account that will be connected to your Pixel.

3. Choose menu option "Pixel" in the top left menu.

Business Manager

4. Click on the button [Set Up Pixel]Find your pixel code

5. Choose the option 2. Install Event Code

install Facebook event pixel code

You can choose to use several different events. The events unlock additional capabilities and data: conversion values, contextual data etc. This helps you to know more about your conversion tracking.

Search

You can place the search event on any search results page to track when people complete a search. To track and optimize for specific search terms please add a search string parameter.

Example code
<script>
	fbq('track', 'Search', {
		search_string: 'training'
	});
</script>

View Content

To track when people visit any content or product detail pages add the view content event. To measure the value of content view conversions you can add parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'ViewContent', {
		value: 0.50,
		currency: 'USD'
	});
</script>

Add to Cart

When a person adds an item to a shopping cart on your Joomla website the add to cart event should be triggered. To measure the value of add to cart conversions please update the parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'AddToCart', {
		value: 35.00,
		currency: 'USD'
	});
</script>

Add to Wishlist

When a person adds or saves an item to a wishlist on your Joomla website the add to wishlist event should be triggered. To measure the value of add to wishlist conversions add parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'AddToWishlist', {
		value: 350.00,
		currency: 'USD'
	});
</script>

Initiate Checkout

When a person enters the checkout flow on your Joomla website the initiate checkout event should be triggered.

Example code
<script>
	fbq('track', 'InitiateCheckout');
</script>

Add Payment Info

When a person adds payment information to an account or in a checkout flow the add payment info event should be triggered.

Example code
<script>
	fbq('track', 'AddPaymentInfo');
</script>

Purchase

Place the purchase event on an order confirmation page or trigger it from a complete order button to indicate that a person has purchased a product. To measure the value of purchase conversions add parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'Purchase', {
		value: 227.25,
		currency: 'USD'
	});
</script>

Lead

Place the lead event on a form confirmation page or trigger it by a submit button when a lead form is completed (ex: when someone signs up for a newsletter). To measure the value of lead conversions add parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'Lead', {
		value: 15.00,
		currency: 'USD'
	});
</script>

Complete Registration

Place the complete registration event on a registration form confirmation page or trigger it by a submit button when a registration form is completed (ex: when someone subscribes to a service). To measure the value of complete registration conversions add parameters for conversion value (amount per content view) and currency.

Example code
<script>
	fbq('track', 'CompleteRegistration', {
		value: 25.00,
		currency: 'USD'
	});
</script>

Custom Event

If you can't find an event that will work for you, you can leverage website actions important to your business even if they aren't included in Facebook standard event. You can send them as custom events. Define the event as a custom conversion, so Facebook understands how to track and optimize for these events. Then modify the code to add a custom event name that is meaningful to you and add the parameters for the event.

Example code
<script>
	fbq('track', '<EVENT_NAME>', {
		<parameter_key>: <parameter_value>,
		<parameter_key>: '<parameter_value>'
	});
</script>

6. To track the behavior copy the Facebook pixel event code and modify it with the parameters you like to use.

Insert the Facebook event pixel on your web page

Inject the code between <script> tags after the closing <head> tag in your Joomla! template, and only on the pages that it should be triggered or fired. When you do this you allow the event code to load along with the pixel base code when the page loads.

Using PixTracker to make it easy to insert and manage the pixel codes

There are several ways of injecting it, but of course, we prefer to use our extension to add the code to articles or menu options. Use PixTracker to manage and insert the codes on specific pages or component menu items. When you start using Facebook Pixel with event codes it soon becomes hard to manage all of the different codes that you have placed on the different pages and PixTracker makes it easy for you to have an overview of your codes and makes it easier to keep them updated.

Do you need to comply with the EU cookie law?

If you have visitors from the EU this bundle will help you to be compliant with the EU law that prohibits you from placing cookies on a device before the visitor has left his/her consent. Use our extension bundle including PixTrackerPixAnalytics and PixCookie Restrict.

Are you using forms, shopping carts, newsletter extensions etc on your Joomla website?

Check out the specific extension best practices to add code to trigger events and report them back to Facebook.

Next step

Now when you have the Facebook Pixel installed the next step is to create Facebook Audiences in business.facebook.com We will soon release a blog post on how you create Facebook Audiences. Keep your eyes open for it.

  • Sarah Watz

    Sarah Watz

    Since the mid-90s, Sarah has worked with sales and digital marketing and in 2003 she started the digital agency Pixpro. She is a well sought-after speaker and is a devoted member of both the Joomla! and the Infusionsoft community.