Dynamically install MCFX Pixel if the page does not have it yet

gerard_reyes Posted by: Gerard Reyes Date Posted: November 18, 2024
Back to Case Studies

Issue

The client has specifically configured MCFX Pixel tags in Google Tag Manager for specific pages.

We cannot apply the default MCFX Pixel to all pages as it will conflict with the configured page.

Solution

Add a custom code to all pages that check first if there is an MCFX Pixel already installed. If there is none, then install it. Else, do nothing, thereby preserving the configured MCFX Pixel.

<script>
(function() {
     if ('undefined' == typeof mcfx) {
         //Put MCFX Pixel code here
     }
})();
</script>

Achievement

MCFX Pixel is installed for pages that need it.

Snippet/Screenshot/Link

Code: Screenshot

Task: Link