KEMBAR78
Facebook Pixel Via GTM Using GA4 Data Layer Schema | PDF | Computer Programming | Computing
0% found this document useful (0 votes)
190 views5 pages

Facebook Pixel Via GTM Using GA4 Data Layer Schema

The document provides a step-by-step guide for setting up Facebook Pixel via Google Tag Manager (GTM) using GA4 Data Layer Schema. It includes scripts for tracking events such as PageView, ViewContent, AddToCart, and Purchase, along with instructions for creating necessary Data Layer Variables and triggers. The document emphasizes the importance of testing the setup in preview mode before final implementation.

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)
190 views5 pages

Facebook Pixel Via GTM Using GA4 Data Layer Schema

The document provides a step-by-step guide for setting up Facebook Pixel via Google Tag Manager (GTM) using GA4 Data Layer Schema. It includes scripts for tracking events such as PageView, ViewContent, AddToCart, and Purchase, along with instructions for creating necessary Data Layer Variables and triggers. The document emphasizes the importance of testing the setup in preview mode before final implementation.

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/ 5

Setup Facebook Pixel via GTM using GA4 Data

Layer Schema

<!-- 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', '805025110181864');
</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=805025110181864&ev=PageView&noscript=1"
/></noscript>
1. 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: 'BDT'
});
</script>

Create Data Layer Variables (Name - Data Layer Variable Name) :

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

Trigger:
Event equals: view_item
2. 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>

Create Data Layer Variables (Name - Data Layer Variable Name) :


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

Trigger:
Event equals: add_to_cart
3. Purchase Event:

Step - 01: Create Data layer variable for pushing Purchase value

Name - Data Layer Variable Name


dlv - FB - Purchase value :
ecommerce.purchase.actionField.revenue
or
ecommerce.value

Step - 02: Create Data Layer Variable for Products (Multiple items)

Name - Data Layer Variable Name


dlv - FB - Purchase Product : ecommerce.items

Step - 03: Create Custom JavaScript Variable to push multiple products


info from Array

Name: jsv - FB - Purchase Product - AR


Code:

function() {
var items = {{dlv - FB - Purchase Product}};
return items.map(function(items) { return items.item_id;
}).join();
}

Step - 04: Create Trigger for purchase event


Event equals: purchase

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

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

Source: Combine GTM Product IDs for Facebook Conversion Tags on Magento |
Elevar (getelevar.com)

You might also like