Introduction
Meta Ads remains one of the highest-performing advertising channels in 2026 for reaching qualified audiences on Facebook and Instagram. This tutorial guides you progressively from creating an ad account to installing the pixel and setting up conversion events. You will learn to structure campaigns precisely and avoid common errors that waste budget. Each step includes concrete examples and ready-to-use code.
Prerequisites
- Facebook account and professional page
- Access to Meta Business Suite
- Basic knowledge of HTML and JavaScript
- Accessible website or landing page
Meta Pixel Installation
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Mon Site</title>
<!-- 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', 'VOTRE_PIXEL_ID');
fbq('track', 'PageView');
</script>
</head>
<body>
<!-- Votre contenu -->
</body>
</html>This code installs the base Meta Pixel. Replace VOTRE_PIXEL_ID with the ID provided in Meta Events Manager. The pixel automatically sends the PageView event on every page load.
Adding a Purchase Event
function trackPurchase(orderId, value, currency) {
fbq('track', 'Purchase', {
value: value,
currency: currency,
content_ids: [orderId],
content_type: 'product'
});
}
// Exemple d'appel
trackPurchase('ORD-12345', 49.99, 'EUR');This Purchase event sends sales data to Meta. It is essential for campaign optimization and ROAS tracking. Always send precise numeric values.
Conversion API Configuration
{
"pixel_id": "VOTRE_PIXEL_ID",
"access_token": "VOTRE_ACCESS_TOKEN",
"test_event_code": "TEST12345",
"events": [
{
"event_name": "Purchase",
"event_time": 1700000000,
"user_data": {
"em": "email@exemple.com",
"ph": "33612345678"
},
"custom_data": {
"value": 49.99,
"currency": "EUR"
}
}
]
}This JSON file structures calls to the Conversion API. It enables server-side event sending for better data reliability when third-party cookies are blocked.
Creating a Campaign via the Marketing API
const axios = require('axios');
const accessToken = 'VOTRE_ACCESS_TOKEN';
const accountId = 'act_VOTRE_ACCOUNT_ID';
async function createCampaign() {
const response = await axios.post(
`https://graph.facebook.com/v19.0/${accountId}/campaigns`,
{
name: 'Campagne Débutant 2026',
objective: 'CONVERSIONS',
status: 'PAUSED',
special_ad_categories: []
},
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
console.log(response.data);
}
createCampaign();This Node.js script creates a campaign via Meta's Marketing API. Always use the CONVERSIONS objective for e-commerce campaigns and set status to PAUSED before validation.
Pixel Test Script
#!/bin/bash
curl -X POST \
"https://graph.facebook.com/v19.0/VOTRE_PIXEL_ID/events?access_token=VOTRE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"data": [{
"event_name": "PageView",
"event_time": '$(date +%s)',
"user_data": {"client_ip_address": "127.0.0.1"}
}]
}'This bash script quickly tests sending events to the pixel. Replace the variables before running and check results in Events Manager.
Best Practices
- Always use the Conversion API alongside the browser pixel
- Name campaigns, ad sets, and ads consistently
- Define custom audiences before launching
- Test creatives with limited budgets for 3-5 days
- Enable event verification in Events Manager
Common Mistakes to Avoid
- Forgetting to validate the pixel in Events Manager before launch
- Sending monetary values without currency
- Using the Traffic objective instead of Conversions
- Neglecting daily budget restrictions per ad set
Go Further
Deepen your mastery of Meta Ads and the Conversion API with our certified training: https://learni-group.com/formations