Facebook Pixel Tracking
This boilerplate includes all the essential events, such as AddToCart
, Purchase
, and PageView
. Follow this guide to integrate Facebook Pixel into your store.

Setup events manager
Setup the Facebook event manager to connect all the events. This will be used by the Meta Pixel when running Facebook Ads.
- Create a Facebook business account.
- Go to https://business.facebook.com/events_manager2 and create a new data source
- Copy the Dataset ID and paste it to
NEXT_PUBLIC_FACEBOOK_PIXEL_ID
. - Go to the Settings tab > Traffic Permissions - Websites
- Add you domain name to allow Facebook to track events from your website.
- Go to Overview tab and click Manage Integrations under Active intigrations
- Click Add New Integration > Conversions API > Set up
- Select Set up manually > Next > Conversions API > Next > Finish
- Click the Manage Integrations again > Manage > Start sending events from server
- Scroll down to Generate an Access Token > press Generate Acccess Token > copy the token and add it to
FACEBOOK_ACCESS_TOKEN
Now the events should be intigrated to NextJS. You can now try the event from your whitelisted url from step .5.
Create Shopify webhook
Create a Shopify webhook to handle the Purchase
event when a successful order has been made.
- Go to Settings > Notifications > Webhooks
- Click Create webhook
- Choose the
Order creation
event. Set your URL enpoint (https://yourwebsite.com/api/webhooks/shopify). Select the (latest) API version and click Save. - Copy the webhook secret and add it to
SHOPIFY_WEBHOOK
.