Fix guide · WordPress · medium · about 45 min

TikTok Pixel not firing after cookie consent on WordPress

For the finding “TikTok Pixel does not fire after consent”. Also for: Any website, Shopify, Webflow, Framer.

What this means

The TikTok Pixel script is on your page, but after cookies were accepted, no events were sent to TikTok. As far as TikTok can tell, this page has no visitors.

Why it costs you money:

  • TikTok cannot see page views or conversions (including WooCommerce add-to-carts and purchases) from this page, so campaigns optimize without data and reported results are too low.
  • Audiences built from website visitors stop growing.

How sure we are: if our checker found and accepted your cookie banner, this is reported as critical. If we did not find a banner we could operate, it is reported as high: the pixel may be waiting for a banner we did not recognize. Test it yourself before changing anything.

How to confirm it yourself

Our check runs from a browser in the EU, so EU consent rules on your site apply to it. If your banner only appears for EU visitors, use a VPN or ask a colleague in the EU.

  1. Log out of WordPress, or use a private (incognito) window. Logged-in administrators often get different pages: some tracking plugins skip them, and optimization plugins may only optimize pages for visitors who are not logged in.
  2. Open developer tools (F12), go to the Network tab and filter by analytics.tiktok.com/api.
  3. Load the page and click Accept (accept all) on the cookie banner.
  4. Wait about 5 seconds. You should see a request to analytics.tiktok.com/api/v2/pixel with a page view in its payload ("event": "Pageview"). If nothing appears, the pixel does not fire after consent.
  5. Open another page. If events only appear now, the pixel starts one page too late, and you lose the first page of every visit, often the ad landing page.
  6. Look at the Console tab. ttq is not defined, ttq.holdConsent is not a function or ttq.grantConsent is not a function point straight at causes below.

The TikTok Pixel Helper extension and Test Events in TikTok Events Manager show the same from TikTok’s side. On a WooCommerce store, repeat the test on a product page and after Add to cart.

How to fix

On WordPress the chain is usually: consent plugin, then the plugin, snippet or GTM tag that loads the pixel, with a caching or optimization plugin in between.

  1. Check that the consent plugin records the choice. After clicking Accept, reload: the banner should not come back. If it does, fix the consent plugin first.

  2. Check the pixel’s category. It must sit in a category that your Accept button grants: marketing in most plugins, Advertisement in CookieYes. In Complianz, look at the wizard’s Services step (TikTok under social media) and Complianz > Integrations; in Cookiebot, at the data-cookieconsent value.

  3. If TikTok’s plugin loads the pixel (Marketing > TikTok on WooCommerce sites, TikTok in the dashboard menu otherwise):

    • Its base code and its events are separate inline scripts (IDs starting tiktok-pixel-tracking-handle-header and tiktok-tracking-handle-header); the page view is a separate track('Pageview', ...) line. If your consent plugin holds back only the base code, the event lines run before the pixel exists and the console shows ttq is not defined. Block both together, for example with a Complianz Script Center entry that blocks by the text ttq, in the marketing category.
    • In the plugin’s code (version 1.4.2), it prints the base code whenever a pixel is saved, but adds the page view only while its connection details (access token and ad account) are stored. Base code without a track('Pageview' line in the page source means: reconnect the plugin.
  4. Test without optimization. Temporarily turn off JavaScript optimization in WP Rocket, LiteSpeed Cache, Autoptimize or similar, clear all caches and test again. If the pixel now fires after Accept, the optimization was the cause: these plugins combine, defer or delay scripts, and a consent plugin may not recognize pixel code that was rewritten or merged, so it cannot re-enable it. Turn optimization back on with exclusions:

    • WP Rocket: on the File Optimization tab, add the exclusions to the exclusion field of every JavaScript option you use (for Delay JavaScript execution it is Excluded JavaScript Files).
    • LiteSpeed Cache: use JS Excludes and JS Deferred / Delayed Excludes on the Tuning tab of Page Optimization.
    • Autoptimize: use Exclude scripts from Autoptimize, and consider turning off Also aggregate inline JS.

    Exclude your consent plugin’s scripts (its documentation lists them), analytics.tiktok.com, ttq, and the script folder of the plugin that loads the pixel (tiktok-for-business for TikTok’s plugin). PixelYourSite’s settings show example file paths to exclude.

  5. If PixelYourSite loads the pixel: check that the consent integration you switched on is for the consent plugin you actually use (it marks plugins it cannot find as “not detected”), and test after each change: its documentation does not guarantee every consent plugin works in every setup.

  6. If Pixel Manager for WooCommerce loads the pixel: update it. Its changelog lists consent fixes, for example one in 1.70.0 for an integration that could keep a visitor who allowed marketing denied.

  7. If the pixel is in Google Tag Manager (added by Site Kit, GTM4WP or a theme snippet):

    • Open GTM Preview mode, load the site and click Accept. Check that a consent update appears and ad_storage becomes granted.
    • Check the TikTok tags. Blocked by consent means the consent update did not arrive. Not fired means the trigger never ran.
    • A tag with only an “All Pages” trigger runs once, before the visitor clicks Accept. Add a trigger for the data layer event your consent plugin pushes when consent changes (Preview shows its exact name) and set the tags to fire Once per page. TikTok’s event tags need the base-code tag (named like TT-<pixel ID>-Web-Tag-Pixel_Setup) to fire first, so give it the same trigger.
  8. If you use TikTok’s consent commands in code you pasted yourself (WPCode, a theme field), check the ttq.methods list and the ttq.grantConsent() calls as described in the general guide.

  9. Look for leftovers from an old consent plugin. Search theme files, snippet plugins and page builder code for type="text/plain", data-cookieconsent, data-cookieyes or data-category. A pixel marked for the old plugin stays disabled, because the new plugin does not look for that marker.

  10. Check the console for other errors, including a Content Security Policy that does not allow analytics.tiktok.com, analytics-ipv6.tiktokw.us and ads.tiktok.com.

  11. Clear every cache (plugin, host and CDN) after each change, then test again while logged out.

Common causes

  • The consent plugin holds back the base code of TikTok’s plugin, but not its separate event lines, so the page view fails before the pixel is released.
  • An optimization plugin combines or delays the pixel code, so the consent plugin cannot re-enable it after Accept.
  • The pixel is assigned to a category that the Accept button does not grant.
  • TikTok’s plugin has lost its connection details, so it prints the base code but no page view.
  • The TikTok tags in GTM fire only on the first page view, before consent, or a cache still serves old pages.

How to verify the fix

  1. In a fresh private window, logged out: no pixel requests before Accept, and a page view request within a few seconds after Accept, on the same page.
  2. Reload the page: the page view is sent on load without clicking anything.
  3. Re-run the check on IsPixelWorking. The issue should be gone, and “TikTok Pixel fires before cookie consent” should not appear in its place.

Sources

Guides for your consent tool