Created
October 24, 2018 23:01
-
-
Save tobsn/fbf50e6a16d075268e1eb403ad7bf8b4 to your computer and use it in GitHub Desktop.
Revisions
-
tobsn created this gist
Oct 24, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ <script> (function(){ var FBDATA = { sku: JSON.parse('{{CHECKOUT SKUS}}'), // cookie variable with array of SKUs (products on checkout page) ids: {{A - EDIT THIS - FACEBOOK PIXEL ID LIST}}, // Variable with Pixel IDs host: '{{Page Hostname}}' }; for( var k in FBDATA.ids ) { if( k !== 'all' ) { if( FBDATA.host.indexOf( k ) === -1 ) { continue; } } if( FBDATA.ids[k].length < 1 ) { continue; } for( var kk in FBDATA.ids[k] ) { if( FBDATA.ids[k][kk].indexOf( ':' ) !== -1 ) { if( FBDATA.ids[k][kk].split(':')[0] !== '{{UTM_SOURCE}}' && '{{UTM_SOURCE}}' !== 'faceboook' ) { continue; } } fbq( 'init', FBDATA.ids[k][kk] ); fbq( 'trackSingle', FBDATA.ids[k][kk], 'InitiateCheckout' ); fbq( 'trackSingle', FBDATA.ids[k][kk], 'AddToCart', { content_type: 'product', content_ids: FBDATA.sku }); } } })(); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ <script> (function(){ var FBDATA = { total: '{{PURCHASE TOTAL}}', // conversion purchase total currency: '{{CHECKOUT CURRENCY}}', // currency USD sku: '{{PURCHASE SKU}}', // products SKU string ids: {{A - EDIT THIS - FACEBOOK PIXEL ID LIST}}, // again static variable host: '{{Page Hostname}}' }; for( var k in FBDATA.ids ) { if( k !== 'all' ) { if( FBDATA.host.indexOf( k ) === -1 ) { continue; } } if( FBDATA.ids[k].length < 1 ) { continue; } for( var kk in FBDATA.ids[k] ) { if( FBDATA.ids[k][kk].indexOf( ':' ) !== -1 ) { if( FBDATA.ids[k][kk].split(':')[0] !== '{{UTM_SOURCE}}' && '{{UTM_SOURCE}}' !== 'faceboook' ) { continue; } } fbq( 'init', FBDATA.ids[k][kk] ); fbq( 'trackSingle', FBDATA.ids[k][kk], 'Purchase', { value: ((FBDATA.total!=='')?(FBDATA.total*1):100), currency: ((FBDATA.currency!=='')?FBDATA.currency:'USD'), content_type: 'product', content_id: FBDATA.sku }); } } })(); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ <script> (function(){ var FBDATA = { ids: {{A - EDIT THIS - FACEBOOK PIXEL ID LIST}}, host: '{{Page Hostname}}' }; for( var k in FBDATA.ids ) { if( k !== 'all' ) { if( FBDATA.host.indexOf( k ) === -1 ) { continue; } } if( FBDATA.ids[k].length < 1 ) { continue; } for( var kk in FBDATA.ids[k] ) { if( FBDATA.ids[k][kk].indexOf( ':' ) !== -1 ) { if( FBDATA.ids[k][kk].split(':')[0] !== '{{UTM_SOURCE}}' && '{{UTM_SOURCE}}' !== 'faceboook' ) { continue; } } fbq( 'init', FBDATA.ids[k][kk] ); fbq( 'trackSingle', FBDATA.ids[k][kk], 'PageView' ); } } })(); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ function(){ return { 'all': [ // global not domain specific '123123123', // if no source is defined it defaults to facebook as utm_source 'by-utm-source-name:123123123' // utm-source:pixel-id or just pixel-id ], 'by-domain.com': [ // for if more than one domain is in play 'some-affiliates-pixel:123123123' ], }; }