Skip to main content

Meta Ads

If you use Meta Ads (formerly Facebook Ads) with Google Tag Manager, we recommend a small modification to the standard base pixel code to ensure it works correctly with consent changes.

Prevent Redundant Pixel Initialization

When a consumer's consent changes, TrueVault triggers a Consent Changed event in Google Tag Manager. This causes GTM to re-evaluate which tags should be active on the page.

The standard Meta Ads base pixel (as suggested in the Meta Pixel documentation) contains code that initializes the fbq object and tracks a PageView. If this base pixel is re-executed by GTM during a consent change, it can result in redundant tracking calls.

To prevent this, wrap the entire Meta Ads base pixel snippet in a check to see if the fbq object is already defined:

<script>
if (typeof fbq === 'undefined') {
/*... Meta Ads base pixel code from their documentation here... */
}
</script>

By adding if (typeof fbq === 'undefined') { ... }, you ensure that the initialization and the initial PageView event only run once, even if GTM re-evaluates the tag when consent is updated.