Skip to content
Vietnam Trusted BrandsServing the Vietnamese business community since 2013

Guide · November 24, 2017

Facebook Pixel Setup: Track Sales From Your Ads

By the editorial panel · Vietnam Trusted Brands

Facebook pixel setup lets you see which sales come from your Facebook ads. You paste a small piece of code on your website. Then you tell Facebook which actions matter, such as a purchase. Finally, you test that it works before you spend money on ads.

What the pixel does

The Facebook pixel is a short piece of JavaScript code. It runs when a person opens a page on your site. It tells Facebook that this visit happened, and it can tell Facebook what the person did there.

This helps you in three ways. You can count sales and sign-ups that came from your ads. You can build lists of people who visited your site, so you can show ads to them again. Facebook can also use this data to show your ads to more people who are likely to buy.

Facebook now offers one pixel for all of this. In the past, advertisers used a conversion tracking pixel and a separate custom audience pixel. The single pixel replaced both, so you only install one piece of code.

Sources: Facebook for Developers, Migrating Pixels and Conversion Tracking (Facebook Pixel documentation).

Step 1: Create your pixel

Log in to your Facebook ads account. Find the pixel section in Ads Manager and create a pixel. Give it a name that matches your business. One pixel is enough for most small shops, even if you run many ad campaigns.

Facebook then shows you the base code. The base code is the same on every page. Copy it. Keep the pixel ID that Facebook shows you, because you will need it to check your work later.

Step 2: Put the base code on every page

Paste the base code between the opening and closing head tags of every page on your site. If you use a website platform, look for a spot called header scripts or custom code. Add it there once, and the platform will place it on all pages.

The base code sends a PageView event. This fires each time the pixel loads. It counts your visits, and it is the start of every audience you build.

If a web developer manages your site, send them the code and ask for it on all pages. Do not paste it in only one place. A pixel that is missing from some pages gives you numbers that are too low.

Sources: Facebook for Developers, Pixel Code Reference (base code and PageView).

Step 3: Add standard events for the actions you care about

The base code counts visits. To count sales, you add standard events. These are fixed names that Facebook understands. Some common ones are ViewContent, Search, AddToCart, InitiateCheckout, Purchase, Lead and CompleteRegistration.

You add an event with one line of code. It goes on the page where the action happens, after the base code. For example, put this on your thank you page after a sale:

fbq('track', 'Purchase', {value: 30.00, currency: 'USD'});

Change the value and currency to match the real order. Vietnamese shops that charge in dong can use the code VND with the real total. Some actions need a click instead of a page load, such as pressing an Add to Cart button. For those, call the same line when the click happens.

Start small. Track the three or four actions that lead to a sale on your site. Too many events make the reports hard to read.

Sources: Facebook for Developers, Pixel Code Reference (standard events and the Purchase example); Facebook for Developers, Marketing API currencies (VND).

Step 4: Test before you spend

Never start a paid campaign before you test. Facebook offers a Chrome extension called the Facebook Pixel Helper. Install it in Chrome and visit your own site. The code icon next to the address bar turns blue when it finds a pixel on the page.

Click the icon. It lists the pixels it found and whether they loaded. Walk through your site like a customer. Open a product, add it to the cart, and finish a test order if you can. Check that each step shows the right event.

The Pixel Helper also shows warnings. Common ones say the pixel fired twice, or that an event name is not a standard event, such as Purchased instead of Purchase. Fix each warning, then reload the page and check again.

Common mistakes to avoid

First, do not paste the pixel only on the home page. Second, do not use a made-up value on the Purchase event. Your reports will be wrong if the number is wrong. Third, do not install the code twice by mistake. Check whether your website platform already has a field for the pixel ID before you add code by hand.

Fourth, tell visitors that you collect data. A clear privacy notice builds trust. Add a short line to your privacy page that says your site uses Facebook tools to measure ads. Check the rules that apply to your business.

Last, give the pixel a few days to gather data. Early numbers are small. Look at them after you have real orders, and then use them to decide where your ad money goes.

Sources: Facebook for Developers, Pixel Helper documentation.

Quick checklist

Create one pixel. Paste the base code on every page. Add events for the key actions. Test with the Pixel Helper. Fix every warning. Then start your ads.