TL;DR
Meta Pixel is a JavaScript code that tracks user actions on your website. You can track conversions and create custom audiences with 17 standard events (PageView, Purchase, AddToCart, etc.).
| When | Which Event | Required Parameter |
|---|---|---|
| Page view | PageView | - |
| Product view | ViewContent | content_ids (Advantage+) |
| Add to cart | AddToCart | contents (Advantage+) |
| Checkout start | InitiateCheckout | - |
| Purchase | Purchase | currency, value |
Critical points:
- Multiple pixels → use
trackSingle/trackSingleCustom - CAPI integration → implement deduplication with
eventID - GDPR → apply
fbq('consent', 'revoke/grant')
Facebook Meta Pixel, along with its usage and special cases, forms a comprehensive reference.
Of course, there may be exceptional requirements and special solutions for these needs.
For information and support on “Data Analytics & Measurement”, visit DNOMIA’s website.
Facebook Meta Pixel
When a visitor starts browsing your website and a session begins, they can be associated with many different activities (button clicks, form submissions, product purchases, signing up, etc.) that you offer and/or are automatically collected, including “page views”. In such cases, the Facebook pixel associated with events/activities activates and reports the activities1. This allows you to understand what actions visitors and/or potential customers (who will become your customers after purchase) take after seeing Facebook ad(s), and also makes it possible to reach these people through a custom audience. Additionally, as the number of users and user-related actions increases, Ad Manager will make ads more accurate. This mechanism that ensures ads reach people who are more likely to take specific actions is called conversion optimization.
Standard Events
Events (can be expressed as activities in Google Analytics) represent actions that occur on your website, such as a visitor filling out a form, signing up, and/or making a purchase. For an event to be tracked, Facebook pixel standard code and at least one standard event (PageView) must be installed.
For installation procedures, you can review my article titled How to Set Up Facebook Pixel?.
What actions are defined as standard events?
Standard events are basically defined with track and supported by parameters with specific object properties that allow you to add detailed information about the event if needed.
We can say that the usage structures correspond to GTAG enhanced e-commerce activities2. Therefore, dataLayer usage can be considered a common solution for both Google Analytics and Facebook.
fbq("track", "[parameter]");
A small note here. If there are multiple Facebook Meta Pixels on the website, you may see trackCustom, trackSingle, or trackSingleCustom instead of track. This difference only affects the behavior of the relevant pixel; the code structure generally remains the same.
Below you can see the defined events that can be tracked and their usage under headings3.
AddToCart Usage
Fires when a link and/or button that adds a product to the cart is clicked. Can contain content_ids, content_name, content_type, contents, currency, value values. For Dynamic Ads, content_ids, content_type, and contents are required.
fbq("track", "AddToCart");
By defining content_ids and content_type, we can create targeted campaigns with specific product matches among many products and analyze conversions in detail. contents can be applied to include EAN code or product price(s), id, quantity.
[
{
id: "ABC123",
quantity: 2,
item_price: 5.99,
},
{
id: "XYZ789",
quantity: 2,
item_price: 9.99,
},
];
item_price defines the price of the specific single product, not the total price when there are multiple products. In this case:
fbq("track", "AddToCart", {
content_ids: ["1234"],
content_type: "product", // or 'product_group'
});
fbq("track", "AddToCart", {
contents: [
{
id: "ABC123",
quantity: 2,
item_price: 5.99,
},
{
id: "XYZ789",
quantity: 2,
item_price: 9.99,
},
],
});
For more detailed usage with all parameters:
fbq("track", "AddToCart", {
content_type: "product",
content_ids: ["1234"],
content_name: "ABC Leather Sandal",
content_category: "Shoes",
value: 0.5,
currency: "USD",
});
content_type is determined by the type of IDs being passed, not the number of IDs. Use product when passing individual product or variant IDs (e.g., Shopify variant ID), and product_group when passing parent/group IDs (e.g., Shopify product ID). Additionally, if Product Catalog is active and products are added, content_ids values must match the product IDs there (especially for dynamic ads). If working with multiple Pixel IDs, the AddToCart definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "AddToCart", {
content_type: "product",
content_ids: ["1234"],
});
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=AddToCart&cd[content_type]=product&cd[content_ids]=1234&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For more detailed usage with all parameters:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=AddToCart&cd[content_name]=ABC%20Leather%20Sandal&cd[content_category]=Shoes&cd[content_type]=product&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
AddToWishlist Usage
We can trigger this event when a link and/or button that adds a product to a wishlist is clicked. Can contain content_name, content_category, content_ids, contents, currency, value values.
fbq("track", "AddToWishlist");
For more detailed usage with all parameters:
fbq("track", "AddToWishlist", {
content_ids: ["1234"],
content_name: "ABC Leather Sandal",
content_category: "Shoes",
value: 0.5,
currency: "USD",
});
content_ids can take single or multiple product IDs. If working with multiple Pixel IDs, the AddToWishlist definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "AddToWishlist");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=AddToWishlist&noscript=1"
/></noscript>
AddPaymentInfo Usage
Defines the transaction flow where payment information is added. Can be associated with the click when a potential customer enters invoice and/or payment details and initiates the registration process. Can also be associated with active tab transitions. Can contain content_category, content_ids, contents, currency, value values.
fbq("track", "AddPaymentInfo");
For more detailed usage with all parameters:
fbq("track", "AddPaymentInfo", {
content_ids: ["1234"],
content_name: "ABC Leather Sandal",
content_category: "Shoes",
value: 0.5,
currency: "USD",
});
content_ids can take single or multiple product IDs. If working with multiple Pixel IDs, the AddPaymentInfo definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "AddPaymentInfo");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=AddPaymentInfo&noscript=1"
/></noscript>
CompleteRegistration Usage
Defines when a registration form is submitted / transaction is completed. Can be used for newsletter forms, membership registrations, and request forms. Can contain content_name, currency, status, value values. status sends true (0) if registration is completed, false (1) if not completed.
fbq("track", "CompleteRegistration");
For more detailed usage with all parameters:
fbq("track", "CompleteRegistration", {
content_name: "ABC Leather Sandal",
value: 0.5,
status: 1,
});
If working with multiple Pixel IDs, the CompleteRegistration definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "CompleteRegistration");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=CompleteRegistration&noscript=1"
/></noscript>
Contact Usage
Can be associated when a visitor/user/customer clicks a phone number for contact purposes, sends SMS or email, or starts a chat session to ask questions.
fbq("track", "Contact");
If working with multiple Pixel IDs, the Contact definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Contact");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=Contact&noscript=1"
/></noscript>
CustomizeProduct Usage
This event can be triggered when customization operations (color, size, variation, etc.) are made for a product.
fbq("track", "CustomizeProduct");
If working with multiple Pixel IDs, the CustomizeProduct definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "CustomizeProduct");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=CustomizeProduct&noscript=1"
/></noscript>
Donate Usage
Can be associated when a visitor makes a donation.
fbq("track", "Donate");
If working with multiple Pixel IDs, the Donate definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Donate");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=Donate&noscript=1"
/></noscript>
FindLocation Usage
Can be associated when a user searches for a company or a physical branch address. Additionally, this event can also be used when searching for a specific product/department or unit (information, checkout, returns, exit, etc.) within a branch or store.
fbq("track", "FindLocation");
If working with multiple Pixel IDs, the FindLocation definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "FindLocation");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=FindLocation&noscript=1"
/></noscript>
InitiateCheckout Usage
Can be associated when a potential customer clicks a link or button to start the payment process and proceeds to the purchase flow. Can contain content_category, content_ids, contents, currency, num_items, value values.
fbq("track", "InitiateCheckout");
For more detailed usage with all parameters:
fbq("track", "InitiateCheckout", {
content_ids: ["1234"],
content_category: "snippets",
value: 0.5,
num_ids: 1,
currency: "USD",
});
If working with multiple Pixel IDs, the InitiateCheckout definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "InitiateCheckout");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=InitiateCheckout&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For more detailed usage with all parameters:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=InitiateCheckout&cd[content_category]=snippets&cd[num_ids]=1&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
Lead Usage
Can be associated with a form submission on landing pages. Can contain content_category, content_name, currency, value values.
fbq("track", "Lead");
For more detailed usage with all parameters:
fbq("track", "Lead", {
content_name: "Sign-up", // lp definition
content_category: "B2B",
value: 0.5,
num_ids: 1,
currency: "USD",
});
If working with multiple Pixel IDs, the Lead definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Lead");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Lead&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For more detailed usage with all parameters:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Lead&cd[content_category]=B2B&cd[content_name]=Sign-up&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
PageView Usage
This event is typically triggered by default when visitors view a page. In virtual pages and modal structures like quick product view (virtual pageview), it can also be triggered separately.
fbq("track", "PageView");
If working with multiple Pixel IDs, the PageView definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "PageView");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=PageView&noscript=1"
/></noscript>
Purchase Usage
This event can be triggered when payment processes are completed (when the thank you page is displayed). Can contain content_ids, content_name, content_type, contents, currency, num_items, value values.
currency and value values are required. For dynamic ads, content_ids, content_type, contents values should be used.
fbq("track", "Purchase", {
value: 0.5,
currency: "USD",
});
fbq("track", "Purchase", {
content_name: "ABC Leather Sandal",
content_type: "product",
content_ids: "[1234]",
value: 0.5,
num_ids: 1,
currency: "USD",
});
Let’s also do an additional example with contents:
fbq("track", "Purchase", {
content_type: "product",
contents: [
{
id: "1234",
quantity: 2,
item_price: 10.0,
},
{
id: "4642",
quantity: 1,
item_price: 5.0,
},
],
value: 25.0,
currency: "USD",
});
If working with multiple Pixel IDs, the Purchase definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Purchase", {
value: 0.5,
currency: "USD",
});
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Purchase&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For more detailed usage with all parameters:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Purchase&cd[content_name]=ABC%20Leather%20Sandal&cd[content_category]=Shoes&cd[content_type]=product&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
Search Usage
Can be associated when a visitor searches for a product or content. Can take content_category, content_ids, contents, currency, search_string, value values. search_string takes the search query term.
fbq("track", "Search");
For detailed usage:
fbq("track", "Search", {
content_category: "Sandals",
content_ids: "[1234]",
value: 0.5,
currency: "USD",
search_string: "Man Sandals",
});
If working with multiple Pixel IDs, the Search definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Search");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Search&cd[content_category]=Sandals&cd[content_type]=product&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&cd[search_string]=Man%20Sandals&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
StartTrial Usage
When a visitor accepts a limited (time, usage) trial offer (product, service, or usage). For example, a 15-day free trial offer. Can take currency, predicted_ltv, value values. predicted_ltv is the advertiser’s predicted lifetime value for a subscriber, expressed as a full value.
fbq("track", "StartTrial");
For detailed usage:
fbq("track", "StartTrial", {
value: 0.5,
currency: "USD",
predicted_ltv: 15,
});
If working with multiple Pixel IDs, the StartTrial definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "StartTrial");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=StartTrial&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For detailed usage:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=StartTrial&cd[predicted_ltv]=15&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
SubmitApplication Usage
This event can be used when a visitor applies for a product, service, or program offer. For example, job applications, courses, credit card acquisitions, etc.
fbq("track", "SubmitApplication");
If working with multiple Pixel IDs, the SubmitApplication definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "SubmitApplication");
To use with Img Pixel:
<noscript
><img
height="1"
width="1"
style="display:none"
src="https://www.facebook.com/tr?id='[Facebook-pixel-ID]&ev=SubmitApplication&noscript=1"
/></noscript>
Subscribe Usage
Can be associated when a visitor starts a paid membership for product or service usage. Can take currency, predicted_ltv, value values.
fbq("track", "Subscribe");
Detailed usage:
fbq("track", "Subscribe", {
value: 0.5,
currency: "USD",
predicted_ltv: 15,
});
If working with multiple Pixel IDs, the Subscribe definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "Subscribe");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Subscribe&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For detailed usage:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=Subscribe&cd[predicted_ltv]=15&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
ViewContent Usage
Can be associated when a visitor views a page important to us (product, content, etc.). For example, cart, campaign detail page, special offer, product detail page, and similar. Can take content_ids, content_name, content_type, contents, currency, value values. For dynamic ads, content_ids, content_type, and contents values must be defined.
fbq("track", "ViewContent");
Detailed usage:
fbq("track", "ViewContent", {
content_type: "product",
content_ids: ["1234"],
content_name: "ABC Leather Sandal",
content_category: "Shoes",
value: 0.5,
currency: "USD",
});
If working with multiple Pixel IDs, the ViewContent definition:
fbq("trackSingle", "[Facebook-pixel-ID-2]", "ViewContent");
To use with Img Pixel:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=ViewContent&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
For more detailed usage with all parameters:
<noscript
><img
src="https://www.facebook.com/tr?id=[Facebook-pixel-ID]&ev=ViewContent&cd[content_name]=ABC%20Leather%20Sandal&cd[content_category]=Shoes&cd[content_type]=product&cd[content_ids]=1234&cd[value]=0.50&cd[currency]=USD&noscript=1"
height="1"
width="1"
style="display:none"
/></noscript>
content_type: product vs product_group
The content_type parameter is critical for Advantage+ catalog ads and dynamic retargeting. It determines which level in the Meta catalog the passed IDs should match against.
Meta Catalog Structure
The Meta product catalog has two levels:
- Content ID: Individual product or variant identifier (the
idfield in the catalog) - Item Group ID: Product group identifier that groups different variants (size, color, etc.) of the same product together
In e-commerce platforms (Shopify, WooCommerce, etc.), this structure typically maps as follows:
| Platform Concept | Meta Catalog Equivalent | content_type |
|---|---|---|
| Variant ID (each size/color separate) | Content ID | product |
| Product ID (parent, covers all variants) | Item Group ID | product_group |
Usage Across the E-commerce Funnel
Using different content_type values on different page types is both valid and recommended. The Meta catalog can match at both levels:
// Category / listing page: no variant selected yet, parent ID available
fbq("track", "ViewContent", {
content_type: "product_group",
content_ids: ["7890", "7891", "7892"],
content_category: "Shoes",
});
// Product detail page: specific variant selected
fbq("track", "ViewContent", {
content_type: "product",
content_ids: ["4001"],
content_name: "Blue T-Shirt - Size M",
value: 29.99,
currency: "USD",
});
// Add to cart: selected variant
fbq("track", "AddToCart", {
content_type: "product",
content_ids: ["4001"],
value: 29.99,
currency: "USD",
});
// Purchase: variants in the cart
fbq("track", "Purchase", {
content_type: "product",
contents: [
{ id: "4001", quantity: 1, item_price: 29.99 },
{ id: "5023", quantity: 2, item_price: 49.99 },
],
value: 129.97,
currency: "USD",
});
Common Mistakes
Sending variant IDs with product_group: If content_ids contains variant IDs but you use content_type: 'product_group', Meta will try to look up those IDs as Item Group IDs and find no match in the catalog. Dynamic ads won’t work, and conversion data will be incomplete.
ID format mismatch with catalog: Shopify sends parent product IDs to the pixel by default, but your catalog may contain variant IDs (or vice versa). You need to verify that the IDs sent from the pixel match their counterparts in the catalog exactly. Facebook Pixel Helper can assist with this verification.
Additional Usage and Definitions
The events and parameters mentioned above can be custom defined based on needs. For example, all steps in a payment process can be marked as Step1, Step2, Step3. In this case, the trackCustom content would be:
fbq("trackCustom", "Step4");
We may also want to define additional parameters for the steps we’ve defined.
fbq("trackCustom", "Step4", {
// optional parameters
});
We can make this operation apply only to a specific pixel ID with trackSingleCustom.
fbq("trackSingleCustom", "[Facebook-pixel-ID-2]", "Step4", {
// optional parameters
});
If we want to define a discount coupon (ShareDiscount), mark users who use it, and create additional parameters (promotion):
fbq("trackCustom", "ShareDiscount", {
promotion: "share_discount_20%",
});
We can make this operation apply only to a specific pixel ID with trackSingleCustom.
fbq("trackSingleCustom", "[Facebook-pixel-ID-2]", "ShareDiscount", {
promotion: "share_discount_20%",
});
On the other hand, we can also add custom properties to an existing standard event. For example, let’s add compared product property, campaign name, and promotion code to the Purchase standard event:
fbq("track", "Purchase", {
value: 115.0,
currency: "USD",
contents: [
{
id: "301",
quantity: 1,
item_price: 85.0,
},
{
id: "401",
quantity: 2,
item_price: 15.0,
},
],
content_type: "product",
compared_product: "recommended-banner-shoes",
campaign_name: "discount-banner",
promotion: "share_discount_20%",
});
A typo that may occur when using a standard event (such as writing Purchased instead of Purchase) can cause the operation to fail and return an error. To catch such issues early, you can use the Facebook Pixel Helper extension. Additionally, you can automatically perform event definition operations through Facebook Partners.
Event Tracking
Operations can be performed through Track Event on Page Load or Track Event When Action is Taken on Page options. What are the differences between these tracking definitions?
Track Event on Page Load
: This option can be considered when an important action is performed (completion of a purchase transaction, membership, etc.) and there is a redirect to a confirmation or thank you page. In this case, the relevant code for page load events should be placed within the <head>…</head> tags.
Track Event When Action is Taken on Page : This option can be considered when the activities to be tracked consist of visitors adding products to cart, form confirmation clicks, phone clicks, purchase button clicks, or clicking an important page link. In this case, the event code will be defined through the element (button, link, etc.) associated with the event to be tracked. Since this operation can be used throughout the session after page load, the code can be kept in an external file or along with other JavaScript code.
In addition to these, assigning values to events (Conversion Value as 1 or Currency) is another recommended practice for more detailed analysis.
Using with Conversions API
Browser-side tracking methods have become increasingly unreliable due to ad blockers, ITP (Intelligent Tracking Prevention), and third-party cookie restrictions. According to Meta’s data, approximately 50% of browser-side events are lost.
Conversions API (CAPI) minimizes these losses by providing server-side event transmission. When used with Meta Pixel, data is collected from both browser and server sides, enabling more accurate measurement.
When using Pixel and CAPI together, event deduplication is required to prevent the same event from being counted twice. The eventID parameter is used for this purpose:
fbq(
"track",
"Purchase",
{
value: 115.0,
currency: "USD",
content_type: "product",
content_ids: ["ABC123"],
},
{
eventID: "order-12345-abc", // Unique event identifier
},
);
When the same eventID is sent via CAPI on the server side, Meta matches these two events and records them as a single conversion4.
GDPR Compliance and Consent Management
Under the European Union General Data Protection Regulation (GDPR), explicit consent must be obtained from users for cookie usage. Meta Pixel supports this requirement with the consent API.
// Stop data transmission by default when page loads
fbq("consent", "revoke");
fbq("init", "PIXEL-ID");
fbq("track", "PageView");
// After user accepts cookie policy
fbq("consent", "grant");
In this structure, the revoke call must be made before the init function. After user consent, data transmission starts with the grant call. If you have an existing cookie consent system (tag manager, etc.), you can integrate this structure.
Single Page Application (SPA) Integration
In single page applications (SPA) developed with modern JavaScript frameworks like React, Vue, Angular, standard pixel setup may not be sufficient because URLs change without page refresh. Meta Pixel automatically detects History API changes and triggers PageView events, but manual triggering is required for other events.
// On route change in React Router or similar structure
const trackRouteChange = (pathname) => {
switch (pathname) {
case "/product":
fbq("track", "ViewContent", { content_type: "product" });
break;
case "/cart":
fbq("track", "AddToCart");
break;
case "/checkout":
fbq("track", "InitiateCheckout");
break;
}
};
// Inside useEffect or componentDidUpdate
useEffect(() => {
trackRouteChange(location.pathname);
}, [location.pathname]);
To disable automatic PageView triggering, disablePushState: true can be used but this is generally not recommended.
Limited Data Use (LDU) - US Privacy Regulations
For state-based privacy regulations in the United States (California CCPA, Colorado, Connecticut), Meta offers the Limited Data Use feature. When this feature is enabled, Meta processes data only in a service provider role.
// LDU off (default behavior)
fbq("dataProcessingOptions", []);
// LDU on - Let Meta determine geographic location
fbq("dataProcessingOptions", ["LDU"], 0, 0);
// LDU on - Manual specification for California
fbq("dataProcessingOptions", ["LDU"], 1, 1000);
fbq("init", "PIXEL-ID");
fbq("track", "PageView");
The dataProcessingOptions call must be made before the init function. When LDU is enabled, campaign performance and retargeting capabilities may be restricted.
Note: As of June 2023, LDU applies to California, Colorado, and Connecticut states. This setting does not directly apply to users in Turkey but should be considered in campaigns with global targeting.
Frequently Asked Questions (FAQ)
What is Meta Pixel and what does it do?
Meta Pixel is a JavaScript code added to your website. It tracks visitor actions like page views, add to cart, and purchases. This data is used for Facebook/Instagram ad optimization, custom audience creation, and conversion measurement.
What are Meta Pixel standard events?
There are 17 standard events:
| Event | Use Case |
|---|---|
| PageView | Page view |
| ViewContent | Product/content detail |
| Search | Site search |
| AddToCart | Add to cart |
| AddToWishlist | Add to wishlist |
| InitiateCheckout | Checkout start |
| AddPaymentInfo | Payment info entry |
| Purchase | Purchase |
| Lead | Form submission |
| CompleteRegistration | Registration complete |
| Contact | Contact |
| CustomizeProduct | Product customization |
| Donate | Donation |
| FindLocation | Location search |
| Schedule | Appointment booking |
| StartTrial | Trial start |
| Subscribe | Subscription |
Which parameters are required for the Purchase event?
currency and value are required. If using Advantage+ catalog ads, contents or content_ids parameter is also required.
fbq("track", "Purchase", {
value: 250.0,
currency: "USD", // Required
content_type: "product",
content_ids: ["SKU-123"], // Required for Advantage+
});
How do you manage multiple Meta Pixels?
trackSingle and trackSingleCustom functions are used:
fbq("init", "PIXEL-A");
fbq("init", "PIXEL-B");
// To all pixels
fbq("track", "PageView");
// Only to PIXEL-A
fbq("trackSingle", "PIXEL-A", "Purchase", { value: 100, currency: "USD" });
Why is Conversions API necessary?
Browser-side tracking loses approximately 50% of events due to ad blockers and ITP. Conversions API minimizes these losses by providing server-side data transmission.
How to configure Meta Pixel for GDPR?
fbq("consent", "revoke"); // Stop first
fbq("init", "PIXEL-ID");
fbq("track", "PageView");
// After user gives consent
fbq("consent", "grant");
Summary: Key Takeaways
- 17 standard events are supported,
currencyandvalueare required forPurchase contentsorcontent_idsis required for Advantage+ catalog adstrackSingle/trackSingleCustomshould be used for multiple pixel managementeventIDdeduplication is mandatory when used with Conversions API- Consent API (
revoke/grant) must be used for GDPR compliance - Manual event triggering is required on route changes in SPA applications