Base Code with PageView Event
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1795805000795623');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1795805000795623&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->
Tag | Use Facebook Tag Template for PageView Event |
Trigger | All Pages |
Variable | event_id
|
ViewContent Event:
<script> fbq('track','ViewContent',{ content_type: 'product', content_ids: {{dlv - fb - product id}}, content_name: {{dlv – fb - product name}}, value: {{dlv – fb - product price}}, currency: 'BDT' }); </script> |
Tag | Use Facebook Tag Template for ViewContent Event |
Trigger | Event equals: view_item |
Variable & Parameters | content_type - ( product or product_group ) content_name -{{dlv – fb - product name}} content_ids -{{dlv – fb - product id}} value -{{dlv – fb - product price}} currency -{{dlv – fb - currency}} event_id
|
Data Layer Variables (Name - Data Layer Variable):
dlv - fb - product id : ecommerce.items.0.item_id
dlv – fb - product price : ecommerce.items.0.price
dlv – fb - product name : ecommerce.items.0.item_name
dlv – fb - currency : ecommerce.currency
Add to cart Event
<script> fbq('track','AddToCart',{ content_type: 'product', content_ids: {{dlv - fb - product id}}, content_name: {{dlv – fb - product name}}, value: {{dlv – fb - product price}}, currency: 'BDT' }); </script>
|
Tag | Use Facebook Tag Template for AddToCart Event |
Trigger | Event equals: add_to_cart |
Variable & Parameters | content_type - ( product or product_group ) content_name -{{dlv – fb - product name}} content_ids -{{dlv – fb - product id}} value -{{dlv – fb - product price}} currency -{{dlv – fb - product currency}} event_id
|
Data Layer Variables (Name - Data Layer Variable):
dlv - fb - product id : ecommerce.items.0.item_id
dlv – fb - product price : ecommerce.items.0.price
dlv – fb - product name : ecommerce.items.0.item_name
dlv – fb - currency : ecommerce.currency
Purchase Event:
<script> fbq('track', 'Purchase', { value: {{dlv - FB - Purchase value}}, currency: 'BDT', content_type: 'product', content_name: {{cJS - FB - Purchase Product Name}}, content_ids: {{cJS - FB - Purchase Product ID}}, }); </script> |
Tag | Use Facebook Tag Template for Purchase Event |
Trigger | Event equals: purchase |
Variable & Parameters | content_type - ( product or product_group ) content_name -{{cJS - FB - Purchase Product Name}} content_ids -{{cJS - FB - Purchase Product ID}} value -{{dlv – fb - product price}} currency -{{dlv – fb - product currency}} order_id -{{dlv – fb - Order ID}} event_id
|
Data Layer Variables (Name - Data Layer Variable):
dlv - FB - Purchase value : ecommerce.value
dlv - FB - Order ID : ecommerce.transaction_id
dlv - FB - Purchase Product : ecommerce.items
Custom JavaScript Variable to push multiple products info from Array:
Variable Name: cJS - FB - Purchase Product ID
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_id; }).join(); } |
Variable Name: cJS - FB - Purchase Product Name
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_name; }).join(); } |
InitiateCheckout Event:
Tag | Use Facebook Tag Template for InitiateCheckout Event |
Trigger | Event equals: begin_checkout |
Variable & Parameters | content_type ( product or product_group ) content_name -{{cJS - FB - Purchase Product Name}} content_ids -{{cJS - FB - Purchase Product ID}} value -{{dlv – fb - product price}} currency -{{dlv – fb - product currency}} event_id
|
Data Layer Variables (Name - Data Layer Variable):
dlv - FB - Purchase value : ecommerce.value
dlv - FB - Purchase Product : ecommerce.items
Custom JavaScript Variable to push multiple products info from Array:
Variable Name: cJS - FB - Purchase Product ID
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_id; }).join(); } |
Variable Name: cJS - FB - Purchase Product Name
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_name; }).join(); } |
AddToWishlist Event:
Tag | Use Facebook Tag Template for InitiateCheckout Event |
Trigger | Event equals: begin_checkout |
Variable & Parameters | content_type ( product or product_group ) content_name -{{cJS - FB - Purchase Product Name}} content_ids -{{cJS - FB - Purchase Product ID}} value -{{dlv – fb - product price}} currency -{{dlv – fb - product currency}} event_id
|
Data Layer Variables (Name - Data Layer Variable):
dlv - FB - Purchase value : ecommerce.value
dlv - FB - Purchase Product : ecommerce.items
Custom JavaScript Variable to push multiple products info from Array:
Variable Name: cJS - FB - Purchase Product ID
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_id; }).join(); } |
Variable Name: cJS - FB - Purchase Product Name
function() { var items = {{dlv - FB - Purchase Product}}; return items.map(function(items) { return items.item_name; }).join(); } |
What to do After Setting up Facebook Pixel:
Connecting Pixel with Ad Account
Connecting Pixel with Facebook Catalog
Domain Verification
Setup Aggregated Event Measurement for iOS 14 update
Improve Facebook Event Match Quality
Source: