MeasureSchool logo

Meta Facebook Pixel Purchase & Conversion Tracking with GTM

Is your Facebook Pixel optimized to track conversions separately from regular events?

Your conversions are the most important events that you can track on your website. But if you’re not using the Facebook Pixel’s Purchase Tracking feature, you could be missing out on important conversion data.

In the last guides, we have set up our Facebook Base Tracking Pixel and Custom Event Tracking. Now we need to tell Facebook what to optimize for.

GTM For Beginners

Sign up to the FREE GTM for Beginners Course...

That’s why we need to set up Facebook Pixel Conversion Tracking also called Purchase Tracking in Facebook Ads. Thus, we will set up Facebook Pixel Conversion Tracking and transfer the value of our conversion to Facebook.

🚨 Note: If you’re new to Google Tag Manager, check out our in-depth GTM tutorial.

An overview of what we’ll cover in this guide:

So let’s dive in.

The Purchase Event Explained

Welcome back to our demo shop. In our last guide, we have already installed our Facebook Base Pixel, which you need to have installed in order for other interactions to be picked up. 

I re-installed the Pageview event and the Add To Cart event on button clicks of the Add to Cart button.

Adding Tags for Base Tracking, Pageview, and Event in Google Tag Manager

Now, there is one thing that is missing, which is very important for Facebook ads i.e. purchase tracking. For this, go to Set up and then click Manually Install the Code Yourself

Manual Installation of Code under Set up in Facebook Pixel

We have already installed this Facebook Base Pixel code on our page and if you click Continue, you have the custom events. 

Custom events in Facebook Pixel

For conversion tracking, we want to select the Purchase event. For the Purchase event, you simply deploy the tracking code. 

How to Set Purchase Amount Dynamically in GTM?

If you have a conversion value for example of 99 dollars, and currency as USD, it will make your data much better. The currency is usually not changing but sometimes could be dynamic as well.

Purchase Event Code in Facebook Pixel

Thus, it is obvious that not all of our purchases should be marked as 99 dollars. You would need to dynamically insert this with the help of Google Tag Manager. So just to give you an example, let’s go back to our demo shop and buy a product. 

In any online store, you would land on an order received page, or a thank you page, where you would normally see how much you have spent on your order.

Order received page in our demo shop

This is the amount that we want to send over to Facebook and dynamically fill into the event that we send to Facebook.

How can we get the amount into Google Tag Manager dynamically? Well, there are different methods and we have discussed them in our guide on Conversion Values

The most robust way is to build a custom data layout.

Now since I’m here on a Woocommerce store, I’ve installed a plugin by Thomas Geiger, which is the Google Tag Manager for WordPress. This plugin will fill the data layer for you automatically if you are on a website.

In order to see the data layer, and where the information is, we need to enter our preview and debug mode. To do this, click the Preview button.

Entering Preview mode in Google Tag Manager

So let’s do that and then go through another conversion. Once I’m back on the thank you page, I can look into my data layer and see how it was filled with values. 

In our case, we have this huge data layer push, which is the gtm4wp.orderCompletedEEC. You can note that the transactionTotal here resembles the total amount that was bought by the user. 

You also have a transactionCurrency in here, which you could use if you had different currencies in your store. In our case, that doesn’t really change so I won’t pull this from the data layer.

Data layer for a completed conversion in Google Tag Manager

Create Data Layer Variable 

I’m just going to try to pull the transaction total from the data layer. To do this, I will build a variable in Google Tag Manager.

Build a New User-Defined Variable in Google Tag Manager

Now variables are like place holders, so you can build them dynamically to pull them from places like the data layer. I will Choose variable type as a Data Layer Variable and this will allow me to access the information from the data layer. 

Choose variable type as Data Layer Variable in Google Tag Manager

Give this variable a name. We have named it as dlv-transactionTotal. The only configuration needed is the Data Layer Variable Name.

That is the key that we see in the Javascript object. So in our case, it will be transactionTotal. Click on Save and we have this now available in the Google Tag Manager as a variable.

Data Layer Variable Configuration in Google Tag Manager

Set-up FB Purchase Event Tag 

What does that mean? And where can we use them? 

Well now, we can go to the next step and copy our JavaScript code.

<script>
fbq('track', 'Purchase', {
value: 99,
currency: "USD",
});
</script>
Copying JavaScript code from Facebook Pixel

We then implement this as a New Tag. Here, we will select a Custom HTML tag. 

Choose tag type as Custom HTML in Google Tag Manager

Give the Tag a name and as the HTML code , paste the JavaScript code that you had copied.

Tag Configuration of Custom HTML type Tag in Google Tag Manager

Now we need to customize this because we don’t want all our products to result in 99 dollars once this fires. 

So we will dynamically insert our variable, which can be done with two curly brackets. This opens up a menu with all your different variables in here. You can click on our dlv-transactionTotal, and that should be replaced dynamically with whatever is in the data layer at that time.

Dynamically insert variable from the data layer in Google Tag Manager

Create Conversion Trigger

Next, we can build a trigger and we would want to deploy that on our final checkout page. Thus, we could look at the URL and would want to deploy this on our order-received page if that is in the URL.

Part of the URL that will be deployed on the final checkout page

We’re going to click on the plus sign ( + ) here and create a new trigger.

Creating a New trigger in Google Tag Manager

We will fire this on the pageview tag of our thank you page and name this pv – Thank You.

Naming the trigger in Google Tag Manager

Now, this will be the Page View tag. 

Choosing trigger type as Page View in Google Tag Manager

But this trigger will only fire on Some Page Views, where the Page URL contains our order-received. Let’s Save the trigger.

Trigger Configuration of a Page View trigger in Google Tag Manager

Testing

We’re almost done! Now we just need to deploy and test our Tag.

Save our Facebook Purchase Pixel. 

Saving the Facebook Purchase Pixel in Google Tag Manager

Now, Refresh our page.

Refresh the page in Google Tag Manager

Let’s go through another conversion. Here, when we get to our Order received page, we see that our Fb – Event – Purchase tag has fired.

Tags fired in Google Tag Manager after conversion

Now, in our Facebook Pixel Helper, we see that Purchase information was transferred with the value of 45.00.

This corresponds dynamically to the Checkout total that  was inserted through our variable with the amount of 45. Thus, this works as expected. 

Facebook Pixel Helper displays a dynamically inserted variable

Let’s move over to our Facebook Analytics, and go into the Event Debugging. Again, we see an Event Purchases that was fired with the value of 45.

Purchase Event fired in Facebook Analytics

Creating a Facebook Custom Conversion

Now in Facebook itself, we could use this for our Custom Conversions. Thus, you could create a New Custom Conversion.

For this, click on Custom Conversions→Create Custom Conversion in your Facebook Pixel.

Create Custom Conversion in Facebook for Facebook Pixel Conversion Tracking

Here, choose Purchase Event as a Custom Conversion.

Custom Conversion to measure Purchase event for Facebook Pixel Conversion Tracking

And once this is set up, you will be able to get columns filled that correspond to the conversion value of your campaigns. For example, in the Ads Manager, if you have a campaign, you should be able to see the actual conversion value, in a column, that you can add in your Ads account. 

Go to Ads Manager →  Add other columns… and select Total Conversion Value.

Customizing Columns in Facebook Ads Manager for Facebook Pixel Conversion Tracking

Thus, this column should be filled with the amount that is transferred later on. This will give you some more data on how many clicks you received and how much money you made in the end. So, you will have a meaningful dataset in your account.

Submit Changes and Publish

Now don’t forget that this is currently running on only our browser. We still need to deploy this as a version so that the Tag will fire for all users. To do that you can click the Submit button.

Submit the Workspace Changes in Google Tag Manager

Now, enter a Version Name, and Publish this to all your users so it is live on your website. Thus, this is how you set up Facebook Pixel Conversion Tracking for purchases.

Publishing a version for purchase tracking in Google Tag Manager

FAQ

How can I set up Facebook Pixel Conversion Tracking with GTM?

To set up Facebook Pixel Conversion Tracking with Google Tag Manager (GTM), follow these steps:

1. Install the Facebook Base Pixel on your website.
2. Access the Facebook Pixel settings and manually install the tracking code.
3. Select the Purchase event for conversion tracking.
4. Set up a variable in GTM to dynamically pull the purchase amount from the data layer.
5. Create a custom HTML tag in GTM and insert the JavaScript code provided by Facebook, dynamically inserting the purchase amount variable.
6. Create a trigger in GTM to fire the tag on the final checkout page or order-received page.
7. Save and test the Facebook Purchase Pixel to ensure it is firing correctly.
8. Create a custom conversion in Facebook using the Purchase event.
9. Publish the changes in GTM to make the tracking live for all users.

How can I verify if the Facebook Purchase Pixel is working correctly?

You can verify if the Facebook Purchase Pixel is working correctly by following these steps:

1. Install the Facebook Pixel Helper browser extension.
2. Visit the order-received or thank you page on your website.
3. Open the Facebook Pixel Helper extension and check if the Purchase event is detected and if the correct value is displayed.

How can I use Facebook Pixel Conversion Tracking data in Facebook Ads Manager?

Once you have set up Facebook Pixel Conversion Tracking, you can use the conversion data in Facebook Ads Manager to measure the performance of your campaigns. You can customize the columns in Ads Manager to display the total conversion value and gain insights into the clicks and revenue generated by your campaigns.

Summary

Alright, so there you have it! This is how you can set up Facebook Pixel conversion tracking for various user actions with the help of Google Tag Manager. In this guide, we learned how to set it up particularly for Purchase tracking. 

In order to build a higher quality audience in your Facebook Ads, you can delay Facebook Pixel and eliminate bounced users.

Are you tracking your purchase & conversion events? Let us know in the comments below!

MeasureMasters

REOPENED!

Master Data & Analytics with MeasureMasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more

Related Posts

Subscribe
Notify of
guest