Neil Patel

I hope you enjoy reading this blog post. If you want my team to just do your marketing for you, click here.

How to Use Events to Optimize Your Facebook And Google Ads

Your website is bustling with activity. Visitors are constantly interacting with it.

But are you taking full advantage of everything that’s happening on your website for your paid marketing? 

Every interaction a visitor has with your website… a pageview, a click… can be used to better understand your audience

And when you understand your audience you can target them in a smarter way, and get more bang for your buck from your paid campaigns on Facebook and Google.

Both Facebook and Google refer to these user interactions as Events. They allow you to track them using a tracking code installed on your website.

What Are Events?

Events are user interactions that don’t involve loading another page on your website.

In e-commerce, the prime example of an event is Add to Cart.

Another event can be filling out a field in a form, as opposed to a form completion that usually triggers loading a “thank you” page. Filling out one or more fields without submission (also known form abandonment) can also be recorded as an event.

In essence, you can record any action a user makes as an event, such as watching a video, clicking on a link, or even downloading a PDF.

Why Events Are Important

Events are important because they indicate the intent of your website visitors and which ones are more likely to become a customer or a lead.

If a visitor watched a video on your website, it demonstrates an interest in your offering. 

In e-commerce, even if a visitor did not complete a purchase, an abandoned cart shows a high purchase intent. Sure, something has prevented the visitor from completing the purchase, but any visitor who got that far is worth your attention. 

By tracking events you’ll be able to make a more focused offer to these users in your paid campaigns.

How you may ask?

By injecting the events tracking data into your paid campaigns and using this data for more precise targeting and an optimized offering.

Think about it, if you can group together all the visitors who watched a certain video and set up a customized campaign for them that referenced what they saw in the video, wouldn’t that make for a far more effective campaign than a generic awareness message?

It sure will.

Let’s discuss how you can use event tracking to get more out of your ad campaigns on Facebook and Google.

How to Set Up Events on Your Website

With both Facebook and Google, you’ll need to use code for setting up events on your website.

So lets go over how you do that…

Setting Up Events Using Facebook’s Pixel

Standard events on Facebook include:

  • View content
  • Search
  • Add to cart
  • Add to wishlist
  • Initiate checkout
  • Add payment info
  • Make purchase
  • Lead
  • Complete registration

Here is the official Facebook guide for setting up events.

First, you need to verify that you already have the Facebook Pixel code embedded in the header code of every page of your website, between the <head> and </head> tags. If you don’t, first go ahead and insert the base Pixel code.

Next, select the event that you wish to track for a specific page from Facebook’s list of events. Let’s say Add to Cart event, which looks like this:

fbq(‘track’, ‘AddToCart’);

Paste the Add to Cart event code above the </script> tag.

Here’s how it should look:

Here’s what each number in the image stands for:

  1. Your header code
  2. Your base Facebook Pixel code (the ID number is unique to every website)
  3. The specific event code

You’ll need to repeat this on every page you want to track one or multiple events. Each page needs its relevant event code.

Event Tracking Setup Using Google Analytics

You can also track events in Google Analytics for even more insight. For event tracking in Google Analytics, you’ll need to create custom code snippets for every event.

Here is the official Google Analytics guide for setting up events.

The code is then added to the link code of the item or action you want to track so when the item is clicked, it will be displayed as an event in Google Analytics.

The event code is made of four elements – two required elements and two optional elements:

  • Category (required) – defines a group of actions you want to track
  • Action (required) – the type of action you want to track
  • Label (optional) – for your monitoring convenience, stating what’s the event is about
  • Value (optional) – assigning a numeric value to the event; can be monetary value, or just a scale

The basic structure of an event code looks like this:

onclick=”ga(‘send’, ‘event’, ‘Category’, ‘Action’, ‘Label’, ‘Value’);”

The code should be added within the href link code, before the link text:

<a href=”” onclick=”ga(‘send’, ‘event’, ‘PDF’, ‘Download’, ‘Company Brochure – PDF Download’);“>Download Our Brochure</a>

In the example above, no Value was assigned to this event.

There Must Be a Better Way

All this event data needs to be injected into your paid campaigns in order to optimize them but before we get into that, let’s talk about the elephant in the room.


Dealing with code isn’t ideal for marketers. It’s just not our forte. 

It holds us back since constant optimization is one of the core principles of online marketing. 

And when you need your development team for every act of optimization, well, it’s not ideal.

Is there a better way to track events on your website? Yes. There’s a tool called Oribi that offers exactly that – no code event tracking. 

Oribi tracks every interaction on your website, page views, and button clicks, automatically. It collects all this data and makes it all available to you. Even when you make changes to your website, like adding a page or changing buttons, events are updated dynamically. As said, all of this is done without any code business on your behalf. 

Here’s how event tracking looks in Oribi:

The value here is apparent. You don’t need to decide which events to track, and you don’t need your development team to track it for you. Everything is tracked for you. You just need to follow the data.

Using Event Data to Optimize Your Paid Campaigns

Now you can use all this event data that you collected so diligently to better segment and optimize your paid campaigns and get more return on your ad spend.

There are two main objectives for tracking event data:

  1. Internal – being able to analyze how visitors are interacting with your website and from that optimizing the UX (user experience)
  2. External – exporting the data to your paid campaigns to better segment them – group together audiences according to their place in the funnel and specific interests in order to deliver more relevant messages

Let’s look again at the Add to Cart event. As mentioned, adding an item to a cart shows a high purchase intent. These visitors, even if didn’t complete the purchase, declared their interest in your product.

They are ‘worth your efforts’ to continue and court them in the hope they will complete a purchase in the future.

But they are all different, and you can better understand them based on the item, or items, they chose. 

If you could, for example, group together all those visitors who added a shirt and then group together those who added a pair of shoes – wouldn’t your customized paid campaigns for these two distinct groups be so much more valuable? 

You’ll be able to deliver a highly relevant message, or offering, in your ads.

This is just the tip of the iceberg as far as segmentation and optimization of your paid campaigns that can be achieved with event tracking.

Two Main Use Cases for Ad Campaign Optimization Based on Event Tracking

Both Facebook and Google offer very strong optimization capabilities for their ad campaigns.

There are two objectives for this:

  1. Ability to segment your audience in order to deliver a highly relevant message (the more segmented the audience is, the more relevant your message can be)
  2. Ability to reach new audiences that are also relevant to your offering

Let’s look at how these objectives are achieved through specific features in Facebook and Google ad campaigns.

Facebook’s Retargeting and Google’s Remarketing

The simplest way to explain the Remarketing feature is this:

When you visit a website, a tracking cookie is installed on your browser (yes, that’s the famous cookies message you now see everywhere). After you leave the website, you begin to see display ads from that website.

This is the remarketing feature: it allows advertisers to show you ads of the website you visited on other websites.

The ads can be general, just a reminder of the brand, but they also can be more personalized. The more directly related the ad is to the content you viewed, the impact it will make, thus increasing the likelihood of a purchase or return visit.

Let’s say you browsed a vacation apartments website. You looked at apartments in Lisbon, but didn’t make a reservation. A couple of days later, while scrolling down your Facebook feed, you all of a sudden see an ad that says “Still thinking about Lisbon?” 

Now that’s powerful. It will stop your scrolling. It will make you think about Lisbon again. If you clicked the ad, it would take you back straight to the Lisbon section of that vacation apartments’ website.

So by tracking events – in this case browsing a specific page – you are able to deliver highly targeted, super relevant, and hopefully mighty engaging ads to audience that already demonstrated interest in your offering.

Facebook’s Lookalike Audience and Google’s Similar Audience

The simplest way to explain the Lookalike (Similar Audience) feature is this:

Based on your audience attributes, Facebook and Google are able to target similar people and show them your ads.

Behind this simple explanation, there is a highly complex algorithm able to locate people with similar interests, demographics, location, and professional background.

Facebook and Google are able to do this thanks to the vast amounts of data they have on their users.

Let’s say you track a video as an event. The video is a top-of-the-funnel content that explains the benefits of using the app you are offering. Website visitors who watched the video are “recorded.”

You can define the visitors who watched the video as a specific “audience” in Facebook or Google Analytics. 

Then, the algorithm finds similarities between the visitors who watched the video and based on this data, can show your ads to other people who never watched the video but share the same similarities with your audience.

This is an incredible tool to expand your potential audience and reach people that are likely to be interested in your offering. This gets you more value on your ad spend.

Connecting the Dots: Events, Audience, and Targeting

So, now you know how Facebook and Google can help you refine and optimize ad campaigns, but what is the process to set it all up?

The first part of the chain is identifying the events and inserting the proper codes for all pages and types of events. We’ve already covered how to set them up, both on Facebook and Google Analytics. 

How you define an event is crucial for the success of the campaign and determines which strategy you’ll use either remarketing or a lookalike (similar) audience.

Once you have the events set up, it’s time to connect them to your ad campaign. In this context, “connect” means enabling Facebook and Google to use the data collected from the event tracking to optimize the ad campaign.

Facebook Event Tracking Ad Optimization

Let’s start with the easier of the two. 

Once you inserted the event tracking code to the various pages of your website, the events data is available for you on your Ads Manager. 

As opposed to Google, where you need to first import the event data from Google Analytics to Google Ads (we’ll get to how to do it in a sec), on Facebook this action is taken care of for you.

Still, you’ll need to locate this data. Here’s how:

First, log in to Ads Manager and click the Pixels tab…

Then, on the left, choose “data sources”, it will take you to your pixel…

Now you’ll see a general breakdown of your events…

And to give you an overview of this report, a few things you should know:

  • Events received is the total number of events recorded by the pixel
  • Top events list the highest-performing events
  • Activity shows the number of events recorded per day for the past week

Now, I want you to click on the “details button”.

Here you can see the actual breakdown of events, by volume and date. You can segment the visitors based on their actions, as we discussed before, or use the different segmentation for Lookalike audience creation.

Since you are already in Facebook Ads Manager, all the information is available for campaign targeting and optimization.

Google Analytics and AdSense Event Tracking Optimization

It’s a two-step process. First, you need to define the events in Google Analytics, and then import them into Google Ads.

Step #1: Define the event in Google Analytics

In your Analytics account, click the “Admin” tab in the bottom left corner. Then click the “Goals” tab.

Select “+New Goal”…

Choose the “Custom” option…

Name your goal…

Select “Event” option…

Now you’ll need to refer to the four elements you defined in the event code you had inserted for the specific event. This:

onclick=”ga(‘send’, ‘event’, ‘Category’, ‘Action’, ‘Label’, ‘Value’);”

The Goal you’re creating will have a specific box for each value. It looks like this:

The text you are entering here must be identical to the text in the code. If it won’t, the event won’t be recorded.

You’ll need to repeat the process above with every event you’re tracking.

Step #2: Import the event into Google Ads

In your Google Ads account, click the “Tools” tab at the top navigation bar. Select “Conversions” from the dropdown menu.

On the left side of the page, click “Google Analytics”…

You’ll see a list of all the goals you defined in Analytics…

Select the ones you want to import. Then click “Import”.

And you’re done. The events you track on your website are finally available for segmenting your remarketing campaigns and creating similar audiences.

If you don’t want to this yourself, Oribi can also do it for you.


Event tracking provides you with valuable data on your website visitors, such as level of intent, specific interests, and place in the funnel.

This provides better optimization of your paid ad campaigns on Facebook and Google.

You should use event data to deliver highly relevant and effective remarketing ads to segmented audiences who have already visited your website.

You should also use event data as the base for creating lookalike or similar audiences for ad campaigns targeting potential audiences who have not yet visited your website. 

By optimizing your paid ad campaigns with event data you’ll be able to better engage users, increase your conversion rate, and get more of your ad spend which results in less money for more clicks.

Have you tried event tracking to help optimize your Facebook of Google ad campaigns?

Consulting with Neil Patel

See How My Agency Can Drive More Traffic to Your Website

  • SEO - unlock more SEO traffic. See real results.
  • Content Marketing - our team creates epic content that will get shared, get links, and attract traffic.
  • Paid Media - effective paid strategies with clear ROI.

Book a Call

Are You Using Google Ads? Try Our FREE Ads Grader!

Stop wasting money and unlock the hidden potential of your advertising.

  • Discover the power of intentional advertising.
  • Reach your ideal target audience.
  • Maximize ad spend efficiency.
Ads Grader