0% found this document useful (0 votes)
16 views

Facebook Pixel With Multiple Dynamic Value Tracking

The document provides a detailed guide on implementing Facebook Pixel for tracking various e-commerce events such as purchases, page views, and add-to-cart actions on a WordPress site. It outlines the necessary steps to create data layer variables, custom JavaScript variables, and the corresponding tracking scripts for each event. Additionally, it includes references to external resources for further assistance in setting up these tracking functionalities.

Uploaded by

showeb443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Facebook Pixel With Multiple Dynamic Value Tracking

The document provides a detailed guide on implementing Facebook Pixel for tracking various e-commerce events such as purchases, page views, and add-to-cart actions on a WordPress site. It outlines the necessary steps to create data layer variables, custom JavaScript variables, and the corresponding tracking scripts for each event. Additionally, it includes references to external resources for further assistance in setting up these tracking functionalities.

Uploaded by

showeb443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

<!

-- Facebook 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', '400826941170566');

</script>

<!-- End Facebook Pixel Code -->

<script>

fbq('track', 'PageView');

</script>

<noscript><img height="1" width="1" style="display:none"


src="https://www.facebook.com/tr?
id=400826941170566&ev=PageView&noscript=1"
/></noscript>
Facebook Pixel with Multiple Dynamic value Tracking

Step-1: Trigger for purchase event for WordPress


Event Name (Taken from Data layer): gtm4wp.orderCompletedEEC
Step-2: Create Data layer variable for pushing Purchase value
Data layer Variable Name(Taken from Data layer):
ecommerce.purchase.actionField.revenue

Variable Name: dlv - FB - Purchase value


Step-3: Create Data Layer Variable for Products (Multiple items)
Data layer Variable name: ecommerce.purchase.products

Variable name: dlv - FB - Purchase Product


Step-4: Create Custom JavaScript Variable to push multiple products info
from Array
Variable Name: jsv - FB - Purchase Product - AR

Code:
function() {
var products = {{Variable-FB-Purchase-Product}};
return products.map(function(prod) { return prod.id; });
}

Step-5: Create tag and finally test from preview mode

Code:
<script>
fbq('track', 'Purchase', {
value: {{Variable-FB-Purchase-Value}},
currency: 'BDT',
content_type: 'product',
content_ids: {{Variable-FB-Purchase-Product}},
});
</script>

Purchase Tag

<script>
fbq('track', 'Purchase', {
value: {{dlv - FB - Purchase value}},
currency: 'BDT',
content_type: 'product',
content_ids: {{jsv - FB - Purchase Product -
AR}},
});
</script>
Reference: #GTMTips: Create String From Multiple Object Properties | Simo
Ahava's blog
View Content 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: {{dlv – fb - currency}}
});
</script>

Data Layer Variable:

dlv - fb - product id : ecommerce.detail.products.0.id


dlv – fb - product price : ecommerce.detail.products.0.price
dlv – fb - product name : ecommerce.detail.products.0.name

dlv – fb - currency : ecommerce.currencyCode

Trigger:
Event: gtm.dom
or
Page URL: /product/

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: {{dlv – fb - currency}}
});
</script>

Data Layer Variable:


dlv - fb - product id : ecommerce.detail.products.0.id
dlv – fb - product price : ecommerce.detail.products.0.price

dlv – fb - product name : ecommerce.detail.products.0.name

dlv – fb - currency : ecommerce.currencyCode

Trigger:
Event: gtm4wp.addProductToCartEEC

You might also like