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.

fbq('track', 'Purchase', {
value: 99,
currency: "USD",
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


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


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!


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
4 years ago

Hi Julian, many thanks for your great tutorial. I have 2 questions.
– In this video you advise to use Thomas Geiger’s plugin, but it requires the GTM ID in the settings therefore I suppose it means this will install the GTM code in the header and the body. So I have to remove my manual installation?
– In this video you started to set the purchase custom conversions up, but you just chose the event “Purchase” and after that you close the window, could you please explain how to set it up properly please?
Thank you.

4 years ago

Thank you Julian for your reply, I found the option. And for the second one, I mean could you please explain the full process for setting up the “Purchase” event you start in the video?

Stephen Renton
Stephen Renton
3 years ago

be useful if you added the links here so people can find them easily

Stephen Renton
Stephen Renton
3 years ago

only part 3 shows when u do a seach ..

2 years ago

Hi Julian. When creating custom conversions in facebook now you have the option to fill in conversion value. Should i leave this at 0,00 to let the value from the standard event go through to the custom conversion?

2 years ago

In regards to the PIxel settings, do you recommend tracking events automatically without code or should this be disabled and then implement the steps outlined in the video. Thanks for a great overview, Julian!

de ipan
de ipan
2 years ago

hi Julian, setting conversion tracking for Fb is still the most challenging to me. currency is the only parameter detected. The value still does not show. I have used the plugin and got the data layer transactiontotal which I made as a variable. But, still the value does not show. Would you please advise me what to do?


2 years ago

need to know what if my website is custom PHP and I need to create a data layer manually because no readymade plugins are available.

11 months ago

Hi Julian,

Love the tutorials. I do have a question: I would like to track quantity however unclear on how to ensure quantity comes into play as it’s under
transactionProducts. How would I add this variable into GTM?
 event: “gtm.load”,
 gtm: {uniqueEventId: 3, start: 1111111},
 transactionId: “4747474747”,
 transactionAffiliation: “dummy”,
 transactionTotal: 130,
transactionProducts: [
   sku: “A+B,
   name: “A + B + C”,
   category: “Ticket”,
   price: 130,
   quantity: 1

Last edited 11 months ago by Sachin
11 months ago
Reply to  Sachin

Hi Sachin, You could create a Data Layer Variable with the value transactionProducts.0.quantity to get the quantity. However, this is not the best option as the transactionProducts array might contain multiple products in it. So we would need to go with a more robust solution here. First, create a Data Layer variable to store the transactionProducts array itself. The value should be just transactionProducts. Assume that we have named the Data Layer variable as dlv - transactionProducts. Now create a Custom JavaScript variable using the below code; function() { return {{dlv - transactionProducts}}.reduce(function(acc, cur) { return acc + (cur.quantity); },… Read more »

Blog Categories

Subscribe & Get the Best FB Ads Overview with our FREE Template

FREE Facebook Dashboard Template

Want to find the Best Sources for Learning GTM? Subscribe & Get our FREE Resource Guide

Google Tag Manager FREE Resource Guide

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.