How to add the TikTok Pixel to your site
If you run TikTok ads to your site, the TikTok Pixel tells TikTok which visitors came from your ads and what they did next. TikTok uses that to report results and to find more people like your visitors. You only need it if you advertise on TikTok.
Before you start
- A TikTok Ads Manager account, at ads.tiktok.com.
- Your site's built-in analytics already count your visitors, including visitors from TikTok. The pixel adds nothing there; it is for TikTok's own ad reports.
Step-by-Step Guide
1. Create the pixel in TikTok
In TikTok Ads Manager, go to Tools > Events and choose Web Events. Set up a new pixel, choose to install the pixel code by hand, and copy the base code TikTok gives you. It starts with <script>.
2. Paste it into your site
- In your site admin area, go to Settings > General.
- Scroll down to Custom Scripts, Meta Tags & ads.txt.
- Paste the code into the Header Scripts and Meta Tags field. If something is already there, paste it on a new line below.
- Click Save. Saving makes the pixel live on your site at once.
3. Check it works
Open your site in a new tab, then go back to Tools > Events in TikTok Ads Manager. Your pixel shows as active once TikTok sees a visit, which can take up to an hour. TikTok's free Pixel Helper extension for Chrome also shows whether the pixel loads on a page.
4. Track clicks on your Buy buttons (optional)
The base code counts page views. To count clicks on your Buy buttons as an event, use TikTok's Event Builder in Ads Manager. It lets you pick the buttons on your page and needs no extra code on your site.
Visitors in the UK and EU. The TikTok Pixel sets cookies. If your visitors come from the UK or the EU, the law there says you must ask them first. Add a cookie consent banner before you add the pixel, and set it to hold TikTok's script until the visitor agrees.
🔗 How to add a Cookie Consent banner to your site
Questions and Troubleshooting
Will the pixel slow my site down?
A little. Every tracking script adds work for the visitor's browser. Add it only while you run TikTok ads, and remove it when you stop.
TikTok says my pixel is not active
Check that you clicked Save. Then visit your site again and wait up to an hour. Make sure the whole code block was pasted, from the opening <script> to the closing </script>.
Something on my site broke after I added it
Remove the code from Header Scripts and click Save. Then copy the base code from TikTok again and paste it on its own line.
Can I show my TikTok videos on my site too?
Yes, and that needs no pixel. Add a TikTok Profile section in Design > Live Site Editor, or paste a TikTok video link into Insert media in the text editor of an article.