💡 In this article, you will learn how to fire different Pixel events based on the part of your website a user is in. This article is mainly directed to advertisers that have multiple funnel stages but not multiple products. If you need to fire events based on dynamic variables, or set up Dynamic Product Ads (DPA), refer to the DPA setup article. For basic setup instructions, see Install Meta Pixel using Google Tag Manager.
Adding Pixel events with Google Tag Manager
This is what we are going to do
- Create triggers on GTM
- Add the Pixel modifications for the various events
1) Create Google Tag Managers triggers based on URL path
- Go to Google Tag Manager
- Triggers
- New
- Rename to "Smartly EVENTNAME"
(replace with corresponding event name - we recommend using the standard events when possible) - Choose _Page view_
- Configure trigger type = Window Loaded (this is to make sure it loads after everything else)
- Fire on = SomePage View: Page Path → contains → /product/ (change this based on your website URL structure)
- Create Trigger
Repeat the above steps for each event/funnel stage you need to set up
Such as ViewContent, AddToCart, RegistrationComplete or Purchase. See the list of standard events here.
You should end up with a list of 1 or more triggers
2) Add the Pixel modifications accordingly
If you have done everything right, this is going to be easy.
- Go to GTM
- New tag
- Name the tag according to your event: EVENTNAME
- Select Custom html
- Paste this code (you can add other parameters as well, and replace the value either manually or dynamically
<!-- Facebook DPA Modification Pixel Code by Smartly -->
<script>
fbq('track', 'YOUREVENTNAME', {
value: 10,
currency: 'EUR'
});
</script>
<!-- End Pixel Code -->
- Fire on // Select More
- Select the trigger called "Smartly YOUREVENTNAME" from the triggers you have implemented in section 1 of this article
- Create Tag
Repeat this for each event.
Does it all work?
- Preview and Debug
- Open your website with Chrome browser
- Reload the page
- From the GTM preview, check Tags
- Tags Fired on This page
- Check with Pixel Helper that the Pixel's events are in place - also check that the Pixel ID is correct (the same you see in Smartly settings)
What if it doesn't work?
PRO TIP: Share the preview link with your account manager or our support chat, so we can help you to debug it!