Action<\/li><\/ol>\n\n\n\nJavaScript library load<\/h3>\n\n\n\n
All modern pixels have a JavaScript (JS) library. This library contains all that’s required for the pixel to run smoothly and is loaded from an external file. Using an external file ensures that you’re always loading the most up to date version of the library. Self hosting a technically possible but never recommended.<\/p>\n\n\n\n
Account identifier<\/h3>\n\n\n\n
After the library has loaded, the pixel can be initialized in association with a specific account. This pairing is usually done once, and all consecutive pixel Actions will be associated with that account.<\/p>\n\n\n\n
Action<\/h3>\n\n\n\n
This is now the event we want to track. Most pixels support standard events, for example Page View, Add to Cart and Lead. Some pixels also allow custom events to be sent, to allow more granular custom tracking, for example scroll depth tracking.<\/p>\n\n\n\n
Examples<\/h2>\n\n\n\nFacebook Pixel<\/h3>\n\n\n\n
For the Facebook pixel, we can see a textbook example. The top part, mostly in gibberish, loads the JS library.<\/p>\n\n\n\n
The fbq(‘init…) part associates the specific pixel ID, i.e. 706900066724012.<\/p>\n\n\n\n
The fbq(‘track’…) part fires the specific Action, i.e. PageView.<\/p>\n\n\n\n
The final part, encompassed in <noscript> tags, is for browsers that do not support JS, and loads the image pixel directly from the page’s HTML. You can see that the URL parameters appended to the image load the pixel ID and Action as in the full JS snippet.<\/p>\n\n\n\n
<!-- Facebook Pixel Code -->\n<script>\n !function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n fbq('init', '706900066724012');\n fbq('track', 'PageView');\n<\/script>\n<noscript><img height=\"1\" width=\"1\" style=\"display:none\"\n src=\"https:\/\/www.facebook.com\/tr?id=706900066724012&ev=PageView&noscript=1\"\n\/><\/noscript>\n<!-- End Facebook Pixel Code --><\/code><\/pre>\n\n\n\nGoogle Analytics<\/h3>\n\n\n\n
For Google Analytics, you can see that the JS library loaded references my tracking ID, UA-89735590-3, though its contents don’t change between accounts.<\/p>\n\n\n\n
The activation, gtag(‘config’…) performs two actions: Associates the specific tracking ID and fires the Pageview action.<\/p>\n\n\n\n
<!-- Global site tag (gtag.js) - Google Analytics -->\n<script async src=\"https:\/\/www.googletagmanager.com\/gtag\/js?id=UA-89735590-3\"><\/script>\n<script>\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n\n gtag('config', 'UA-89735590-3');\n<\/script><\/code><\/pre>\n\n\n\nQuora Ads<\/h3>\n\n\n\n
The Quora Ads pixel works just like the Facebook pixel.<\/p>\n\n\n\n
The initial gibberish loads the JS library. The qp(‘init’…) associates the Quora pixel ID and then the Action triggers with qp(‘track’…). Unlike Google Analytics and Facebook, Quora chose ViewContent as the name for the Page View action, but it serves the same purpose.<\/p>\n\n\n\n
The <noscript> tag in Quora is also the same as Facebook’s pixel, with a minor change with the pixel ID sent in a subfolder rather than URL parameter.<\/p>\n\n\n\n
<!-- DO NOT MODIFY -->\n<!-- Quora Pixel Code (JS Helper) -->\n<script>\n!function(q,e,v,n,t,s){if(q.qp) return; n=q.qp=function(){n.qp?n.qp.apply(n,arguments):n.queue.push(arguments);}; n.queue=[];t=document.createElement(e);t.async=!0;t.src=v; s=document.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s);}(window, 'script', 'https:\/\/a.quora.com\/qevents.js');\nqp('init', 'e4a4302c721745a4a7ae79071b4782gb');\nqp('track', 'ViewContent');\n<\/script>\n<noscript><img height=\"1\" width=\"1\" style=\"display:none\" src=\"https:\/\/q.quora.com\/_\/ad\/e4a4302c721745a4a7ae79071b4782fc\/pixel?tag=ViewContent&noscript=1\"\/><\/noscript>\n<!-- End of Quora Pixel Code --><\/code><\/pre>\n\n\n\nBut that’s just the standard pixel, what about other actions?<\/h2>\n\n\n\n
Glad you asked.<\/p>\n\n\n\n
So we understood that the “standard” tracking uses a similar mechanism, but so does the event\/conversion tracking.<\/p>\n\n\n\n
Say you want to track a form submission with a Lead action.<\/p>\n\n\n\n
For Facebook that would require sending:<\/p>\n\n\n\n
fbq('track', 'Lead');\u200e<\/code><\/pre>\n\n\n\nIf you’re using Pinterest Ads, it would similarly be:<\/p>\n\n\n\n
pintrk('lead');<\/code><\/pre>\n\n\n\nOutbrain would look like this:<\/p>\n\n\n\n
obApi('track', 'Lead');<\/code><\/pre>\n\n\n\nYou get the point.<\/p>\n\n\n\n
Pro tip:<\/strong>
When adding the above via GTM, make sure you encompass the in <script> tags<\/p><\/blockquote>\n\n\n\nAnd here’s another tip:
After the tracking pixel has been initialized on the page with the standard tag (Page View action or equivalent), to fire additional actions, all you have to do is trigger this one line. No need for you to load the rest of the code that’s part of the standard tag.<\/p>\n\n\n\n
I see plenty of advertisers failing to implement this correctly. Loading the full tag won’t do any damage, it’s just plain inefficient. <\/p>\n\n\n\n
So long story short, on any page you’ve already loaded the standard tag and you now want to trigger another action, simply call the action’s function. That’s it.<\/p>\n","protected":false},"excerpt":{"rendered":"
Working for almost a decade with various web analytics platforms, I’ve come to realize that almost all platforms, analytics or advertising, behave in pretty much the same way. The reason for this standardization is simply because it just makes sense. The current iteration of these mechanisms is logical and simple to implement, so most platforms […]<\/p>\n","protected":false},"author":1,"featured_media":4308,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-4307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/comments?post=4307"}],"version-history":[{"count":8,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4307\/revisions"}],"predecessor-version":[{"id":4806,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4307\/revisions\/4806"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media\/4308"}],"wp:attachment":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media?parent=4307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/categories?post=4307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/tags?post=4307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}