Using Facebook pixel with Google Tag Manager
30/11/2019
If you're using Google Tag Manager to manage tags for your website, you can add your Facebook pixel to your Google Tag Manager account to measure and optimise the results of your Facebook advertising. Learn about the benefits of installing the Facebook pixel.
Install your pixel
- Log in to your Google Tag Manager account.
- Select your website's container and click Add a new tag.
- Click Custom HTML tag and enter a name for your tag.
- Go to Events Manager and click Details for your pixel.
- Click Set up and select Manually install the code yourself.
- Copy the entire pixel base code, as shown below.
- Return to Google Tag Manager and paste the code in the HTML container.
- Click the Advanced settings drop-down and select Once per page under Tag firing options.
- Under Fire on, select All pages.
- Click Create tag.
Create action-specific tags
Now that you have your base code installed, you can create specific tags for the different types of pages and events on your website (e.g. product page, Add to Basket button, purchase page).
- In Google Tag Manager, select your website's container and click Add a new tag.
- Name your tag, then insert just the snippet of code relating to that event, plus any other variables you want to track. Bear in mind that your variables (e.g. product_ids and product_name) may be different from the example below.
- Click Custom HTML tag and enter a name for your tag.
- Copy and paste the snippet of code relating to the event and any other variables that you want to track. Bear in mind that your variables (e.g. product_ids and product_name) may be different from the example below.
- Under Advanced settings, select Once per event under Tag firing options.
- Under Tag sequencing, tick the box and select your base code tag to ensure this tag fires after your base code.
- Under Fire on, select the trigger that is relevant for your site.
- Click Create tag.
- In the same way, create tags for the other events on your website (e.g. add to basket, purchase). See the examples below.
- When you've finished creating tags, click Publish.
Check if your pixel is working
Once you've uploaded all your events, you should check if your pixel is working correctly. To check that your pixel is working properly on your live site:
- Navigate to the web page that your pixel was added to. If it's working, your pixel detail page in Events Manager will show your pixel's status as Active and you'll see activity reported in the dashboards. Learn more about your pixel data in Events Manager.
- If your pixel's status is No activity yet, you can use the Facebook Pixel Helper to troubleshoot the problem. Once the Pixel Helper is installed in your Chrome browser, a small icon will appear next to your address bar. Navigate to your website in your Chrome browser and click the Pixel Helper icon. You can see which pixel events were found on the page and whether they have loaded successfully, or see troubleshooting tips if there are any issues. Learn more.
* Nguồn: Facebook