To solve this Facebook pixel-related duplicate events error we take an example of an e-commerce website:
Base Code Event-Facebook Pixel
First of all, go to the Facebook base codes under the tags section in the tag manager. Here you can see the tracking code, activate it for all of your website pages from the triggering option. So, you can see here the Facebook pixel number and track is pageview in the code.
Now to check is it working properly, go to your website. Open the Facebook pixel helper extension and you can see it save the event info.
Viewer Content Event
Go to any viewer content page (open any product) from your main page. Here you see its server three in the Facebook pixel helper extension. How it’s been tracking the viewer content. If you go to Facebook viewer content under the tags section in tag manager. It contains the same code in the Facebook base codes but its track is changed to view content and triggering is changed from all pages to view page content where you place the URL of your view page content and that’s why it’s been tracked. So. if you face any problem follow the mentioned settings and it starts working.
Add to cart event-Facebook Pixel
Go to the view content page contain any product in our e-commerce website scenario. Click on the add to cart button and you can see in the Facebook pixel helper the file is saved. How does it work? In order to do that you need to add a tag of add to card. Then put the same code as in the earlier pages but changed the track option with “Add to cart”. So it’s going to help in the Facebook Pixel Issue.
In the triggering option select the add to cart page option with its URL and add the click class which we get from our website. For this right-click on the add to cart button, go to inspect option and here you can find the class of click add to cart button. And also select the equal option in the click class which increases the accuracy.
Checkout and Purchase Event-Facebook Pixel
Now, after adding the product into the cart go to the cart page. Click the checkout option, it generates the checkout event. In order to do that we created an Initiate checkout tag in tag manager with the code that contains initiate checkout as track. And in the triggering option select the initiate checkout page and its URL and select the “ends with” because if you need to order a cavity after that so it’s track too. So it’s going to help in the Facebook Pixel Issue.
After the checkout event when you click purchase, it creates a purchase event. If you go to the purchase tag in tag manager you can see the track contains the purchase option and there is a dynamic value option. This dynamic value option sends data to Facebook that how much price product is purchase by the customer. So it’s going to help in the Facebook Pixel Issue. How do we do this? In order to do that take the purchased invoice page link and paste it in the tag manager preview and it shows the data layer which contains the total purchased data list. Here we get the order purchase total:
We use this data to create a variable in tag manager which then we use in the purchase tag as a dynamic value.
So, this is the complete procedure to fix the duplicate events problem in Facebook pixels using tag manager which is quite useful and easier than using different plugins which required much time for handling and maintenance.