Setting Up Meta Pixel and the Conversions API
We show how to add the Meta Pixel to your site and define standard events, how to set up the server-side Conversions API and how to test your events.

For Meta Pixel setup, you create a new web data source (pixel) in Meta Events Manager and add the base code to your site's head section or to Google Tag Manager. Then you define standard events such as purchase and add to cart, connect the Conversions API to strengthen measurement and verify the events in the Test Events screen.
What Is the Meta Pixel and Why Do You Need It?
The Meta Pixel (formerly the Facebook pixel) is a JavaScript code added to your site that reports visitors' actions to Meta. This is how you see which sale, form or signup your Facebook and Instagram ads brought in.
The pixel's real power goes beyond measurement. Meta's ad system learns from events such as purchases and shows your ad to people who are likely to convert. Custom audiences for re-reaching people who visited your site or looked at a product are also built from pixel data.
Browser-based measurement can miss some events because of ad blockers, browser privacy settings and connection drops. To close this gap, the pixel is used together with the Conversions API, which sends events from the server.
Preparation Before Setup
Open the pixel and the ad account in the business's own portfolio and give the agency only partner access. That way, even if the collaboration changes, the accumulated measurement data and audiences stay with the business. The Meta Pixel does not replace GA4; to use the two together, see our Google Analytics 4 setup guide too.
- A Meta business portfolio (Business Manager) and an ad account that belong to the business
- Access to the site or to the tag manager
- A list of the events you want to measure: product view, add to cart, initiate checkout, purchase, form submission
- Whether your cookie consent setup makes measurement codes depend on consent
Creating the Pixel and the Base Code
Open Meta Events Manager, select Web in the Connect data sources step and give your pixel a name. Then you choose the setup method: adding the code manually, using a partner integration or installing it through Google Tag Manager.
For manual setup, add the base code Meta gives you to the head section of every page. The code sends the PageView event every time the page loads. In the example below, your own pixel ID goes in place of PIXEL_ID; always copy the code from Events Manager.
<!-- 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', 'PIXEL_ID');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=PIXEL_ID&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->With Google Tag Manager
If you use GTM, you can add the base code with a Custom HTML tag and fire it on all pages. Tying events to data layer triggers makes measurement resilient to design changes; details are in our Google Tag Manager setup article.
From the platform admin panel
Some platforms support taking the pixel ID from the panel and sending events themselves. In Aurora's e-commerce platform, the Meta connection maps the product catalog and measures conversions without double counting; the codes are added from the panel.
Standard Events and Parameters
Using the standard event names defined by Meta lets ad optimization and reports work automatically. In the purchase event, value and currency are required; product IDs help catalog ads show the right product.
| Event | When is it sent? |
|---|---|
| ViewContent | When a product or service detail page is opened |
| AddToCart | When a product is added to the cart |
| InitiateCheckout | When the checkout step starts |
| Purchase | When an order is completed |
| Lead | When a form or quote request is submitted |
| CompleteRegistration | When a signup is completed |
fbq('track', 'AddToCart', {
content_ids: ['URN-12'],
content_type: 'product',
value: 1499.90,
currency: 'TRY'
});
// Purchase: eventID is required for deduplication
fbq('track', 'Purchase', {
value: 1499.90,
currency: 'TRY',
content_ids: ['URN-12'],
content_type: 'product'
}, { eventID: 'SIP-10045' });Setting Up the Conversions API
The Conversions API sends events to Meta directly from your server instead of the visitor's browser. It is not affected by ad blockers and passes confirmed data such as orders from the source. Meta recommends using the pixel and the API together for the best results.
For setup, create an access token in the pixel's settings tab in Events Manager. This token is a password: store it only on the server and never put it in browser code or a public repository. Then your server sends a request to the Graph API's events endpoint for every important event.
For small sites without their own server, there are lower-code options such as Meta's partner integrations and the Conversions API Gateway. In a landing page design project that receives ad traffic, the healthiest approach is to verify the pixel and API setup in a test environment before the page goes live; that way no data is lost from the first day of the campaign.
- event_time is the Unix timestamp of the event (in seconds) and must show the moment the event happened.
- Personal data such as email and phone number is sent hashed with SHA-256; format the phone number first as digits only, including the country code.
- Check the Graph API version number in Meta's developer documentation; older versions are retired over time.
curl -X POST "https://graph.facebook.com/v<SURUM>/<PIXEL_ID>/events?access_token=<TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"data": [{
"event_name": "Purchase",
"event_time": 1767225600,
"event_id": "SIP-10045",
"action_source": "website",
"event_source_url": "https://ornek.com/tesekkurler/",
"user_data": {
"em": ["<SHA256_ILE_KARMALANMIS_EPOSTA>"],
"client_ip_address": "203.0.113.10",
"client_user_agent": "Mozilla/5.0 ...",
"fbp": "fb.1.1767225000000.1234567890"
},
"custom_data": { "value": 1499.90, "currency": "TRY" }
}],
"test_event_code": "TEST12345"
}'printf '%s' 'ornek@alanadi.com' | sha256sumDeduplication: Why Are Events Counted Twice?
When the same purchase is sent from both the pixel and the API, Meta needs to understand that they are a single event. This process is called deduplication and depends on two conditions: the event name and the event ID must be exactly the same in both sources.
Note that in the examples above, the same order number is written to eventID on the browser side and to event_id on the server side. If this match is not set up, sales appear doubled in reports and the ad system learns from wrong data.
You can see that deduplication is working in the event details in Events Manager: the same event is listed as received from both the browser and server sources and deduplicated. A small time difference between the two sources is not a problem.
Testing and Verifying Events
The Test Events tab in Events Manager shows events in real time. To see browser events, enter your site's address and take actions in the window that opens; for server events, add the test code shown on screen to the test_event_code field in your request, and remove this field when you go live.
The Meta Pixel Helper browser extension also shows which event runs on which page, with which parameters. A few days after setup, look at the event match quality score in Events Manager; if the score is low, you may need to add more hashed customer information to your server events.
| Problem | Likely cause and fix |
|---|---|
| Event does not appear | The pixel ID is wrong or the code is not published; check with Pixel Helper. |
| Sales are doubled | event_id does not match or the pixel is loaded twice. |
| API request returns an error | The token is invalid, the version is old or event_time is too old; read the error message in the response. |
| Wrong amount | value is sent as text instead of a number or currency is missing. |
Privacy and Consent
The pixel and the Conversions API process personal data. Ad measurement codes must not run before the visitor gives consent, the data sent must be explained in your privacy notice and only necessary information should be shared. For sensitive categories such as health, Meta has additional restrictions.
This article gives general information. Check the current KVKK (Turkish data-protection law, comparable to GDPR) and GDPR rules and your legal advisor on your cookie consent flow, your privacy notice and the transfer of data abroad. If you are wondering which metrics to use to read ad performance, our social media metrics article is a good start.
Frequently Asked Questions
01Are the Facebook pixel and the Meta Pixel the same thing?
Yes. After Facebook's parent company took the name Meta, the tool also came to be called the Meta Pixel. The same pixel is used to measure both Facebook and Instagram ads.
02Is the pixel enough without the Conversions API?
The pixel works on its own, but because of browser-related data loss some conversions may not show up in reports. As the ad budget grows and sales come directly from the site, adding the API noticeably improves the reliability of measurement.
03Do I need a separate setup to track Instagram ads?
No. Instagram ads are measured from the same ad account and with the same pixel. You only need to choose the right pixel and the event to optimize for in the ad set.
When the pixel and the Conversions API are set up together with deduplication rules, you can measure the return on your ad budget with confidence. To set up the measurement infrastructure and manage campaigns with this data, see our digital marketing service, and for Instagram and Facebook content and ad management, our social media solutions. You can also use our SEO and analytics support to interpret the reports.


