Fix guide · WordPress · medium · about 45 min

TikTok Pixel fires before cookie consent on WordPress

For the finding “TikTok Pixel fires before cookie consent”. Also for: Any website, Shopify, Webflow, Framer.

What this means

Your WordPress site shows a cookie banner, but the TikTok Pixel sent data to TikTok while the banner was still waiting for an answer. On WordPress this usually means the pixel is loaded by a plugin, a theme setting or a code snippet that your consent plugin does not control.

Why it costs you money:

  • If you advertise to people in the EU, sending marketing data before consent is a legal risk you probably did not intend to take. TikTok asks advertisers to obtain consents as required by applicable laws. We report the technical behaviour only; we cannot tell you whether your setup is compliant.
  • The banner and the pixel are not connected. When this is fixed in a hurry, the usual result is the opposite problem: the pixel stops firing and your TikTok campaigns lose their data.

How to confirm it yourself

Our check runs from a browser in the EU. If your consent plugin only shows the banner in some regions, use a VPN or ask a colleague in the EU.

  1. Log out of WordPress, or use a private (incognito) window. Some tracking plugins skip administrators, and optimization plugins can serve logged-in users different pages.
  2. Open developer tools (F12), go to the Network tab and filter by analytics.tiktok.com/api.
  3. Load the page. Do not click anything on the cookie banner.
  4. If requests to analytics.tiktok.com/api/v2/pixel appear while the banner is still on screen, the pixel fires before consent. In the payload, event is the event name and context.pixel.code is your pixel ID.
  5. Under Application > Cookies (Chrome) or Storage > Cookies (Firefox), look for TikTok’s advertising cookies _ttp, ttclid and ttcsid_…. If your consent plugin, tracking plugin or GTM blocks the pixel, they should not exist yet. TikTok does not document whether its own consent mode (ttq.holdConsent()) also holds back cookies, so with that route judge by the event requests. With TikTok’s plugin and ?ttclid= in the address you may also see tiktok_ttclid; the plugin sets it from your server, so browser-side blocking does not hold it back.

The TikTok Pixel Helper extension and Test Events in TikTok Events Manager show the same thing (see the general guide).

How to fix

  1. Find every place the pixel comes from. Right-click the page, choose View page source and search for analytics.tiktok.com and ttq.load. The usual sources on WordPress:
    • TikTok’s official plugin, listed as TikTok under Plugins (WooCommerce calls it TikTok for WooCommerce), with settings under Marketing > TikTok, or under TikTok in the dashboard menu on sites without WooCommerce. Its code sits in inline scripts whose IDs start with tiktok-pixel-tracking-handle-header and tiktok-tracking-handle-header.
    • Tracking plugins: PixelYourSite (TikTok is part of PixelYourSite Professional) or Pixel Manager for WooCommerce.
    • A Google Tag Manager (GTM) container with TikTok tags, added by Site Kit by Google, GTM4WP or a theme snippet.
    • Code you pasted yourself: WPCode (Code Snippets > Header & Footer), Elementor Pro’s Custom Code, a theme’s header code field (for example Divi’s Theme Options > Integration tab) or header.php.
  2. Keep one source and remove the others. A second copy usually sits outside your consent setup and also sends events twice (see “Duplicate TikTok events”).
  3. Put that source under consent control. TikTok documents no consent setting for its plugin, and the plugin’s code (version 1.4.2) has no consent check and does not read the WP Consent API. The WP Consent API only shares the visitor’s choice; it blocks nothing. So the blocking has to come from your consent plugin or tracking plugin:
    • Complianz has a built-in TikTok integration. In Complianz > Wizard > Consent > Services, answer yes to “Does your website contain embedded social media content, like buttons, timelines, videos or pixels?” and select TikTok. Complianz then treats scripts that contain tiktok.com as marketing. For TikTok’s plugin that is not enough: in the plugin’s code (version 1.4.2), its events are separate inline scripts (ttq.instance('…').track(...)) without tiktok.com, and its base code has no ttq.page() (the page view is one of those event lines). Complianz then blocks the base code but not the event lines, which fail with ttq is not defined. So add a Script Center entry (Complianz > Integrations) that blocks by the text ttq, in the marketing category: base code and events are then held back and released together. Use the same kind of entry, by URL (analytics.tiktok.com) or by text (ttq), for other code Complianz does not catch.
    • CookieYes: in the Cookie Manager, add the TikTok cookies to the Advertisement category with the script URL pattern analytics.tiktok.com.
    • Cookiebot: use automatic blocking, or for code you pasted yourself use type="text/plain" with data-cookieconsent="marketing". Cookiebot’s WordPress plugin has no add-on for TikTok’s plugin, so test whether automatic blocking catches it.
    • PixelYourSite: in its consent settings, switch on the integration for your consent plugin (ConsentMagic, Cookiebot, Cookie Notice, CookieYes or Real Cookie Banner). For Cookiebot, map TikTok to marketing.
    • Pixel Manager for WooCommerce: update to 1.70.0 or later. Its changelog says opt-in banners from Complianz, Cookiebot, CookieYes and others no longer let pixels fire before the visitor answers (with Explicit Consent Mode off).
    • GTM: in each TikTok tag’s Advanced Settings > Consent Settings, choose Require additional consent for tag to fire and add ad_storage, including the base-code tag TikTok’s setup creates (named like TT-<pixel ID>-Web-Tag-Pixel_Setup). This only works if your consent plugin sends Google Consent Mode updates to GTM.
    • Code you pasted yourself can use TikTok’s consent mode instead: add "holdConsent", "revokeConsent", "grantConsent" to ttq.methods, call ttq.holdConsent() before ttq.load(...), and call ttq.grantConsent() from your consent plugin’s accept event and on every page for visitors who accepted earlier (code in the general guide). TikTok’s plugin writes its own base code without these methods.
  4. Know what browser blocking does not cover. TikTok’s plugin (version 1.4.2) also sends page views and WooCommerce events to the Events API from your server while WordPress builds the page, without a consent check. We cannot see server traffic. If that matters for your assessment, ask TikTok’s plugin support, or use an integration whose documentation says its server events wait for consent too.
  5. Check caching and optimization plugins. WP Rocket, LiteSpeed Cache, Autoptimize and similar plugins can combine, defer or delay scripts, and a consent plugin may no longer recognize pixel code that was merged into a combined file (Complianz’s documentation describes this). Exclude analytics.tiktok.com, ttq, the scripts of the plugin that loads the pixel and your consent plugin’s scripts from combining and delaying, then clear every cache: the plugin’s, your host’s and your CDN’s.
  6. Check the banner’s mode and regions. For EU visitors the banner must ask first (opt-in), not just show a notice.
  7. Make sure “Accept” starts the pixel on the same page, so the landing page view is not lost. See “TikTok Pixel does not fire after consent”.

Common causes

  • TikTok’s plugin was installed, and no consent plugin rule covers its scripts.
  • The base code was added with a snippet plugin, a page builder or a theme field, and the consent plugin was never told about it.
  • Complianz is installed, but TikTok is not selected under social media in its wizard.
  • A tracking plugin loads the pixel, and its consent integration is off or set for a different consent plugin.
  • An optimization plugin combines or delays scripts, so the consent plugin no longer recognizes the pixel code.

How to verify the fix

  1. Clear all caches, then repeat the test above while logged out: no pixel requests before you answer the banner, and, if your consent plugin, tracking plugin or GTM blocks the pixel, no _ttp or ttclid cookies yet.
  2. Click “Accept”: a page view request leaves within a few seconds, on the same page.
  3. In a fresh private window, click “Reject”: no page view or conversion events.
  4. Re-run the check on IsPixelWorking. The issue should be gone, and “TikTok Pixel does not fire after consent” should not appear in its place.

Sources

Guides for your consent tool