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.
- 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.
- Open developer tools (F12), go to the Network tab and filter by
analytics.tiktok.com/api. - Load the page. Do not click anything on the cookie banner.
- If requests to
analytics.tiktok.com/api/v2/pixelappear while the banner is still on screen, the pixel fires before consent. In the payload,eventis the event name andcontext.pixel.codeis your pixel ID. - Under Application > Cookies (Chrome) or Storage > Cookies (Firefox), look for TikTok’s advertising cookies
_ttp,ttclidandttcsid_…. 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 seetiktok_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
- Find every place the pixel comes from. Right-click the page, choose View page source and search for
analytics.tiktok.comandttq.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-headerandtiktok-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.
- 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
- 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”).
- 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.comas 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(...)) withouttiktok.com, and its base code has nottq.page()(the page view is one of those event lines). Complianz then blocks the base code but not the event lines, which fail withttq is not defined. So add a Script Center entry (Complianz > Integrations) that blocks by the textttq, 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"withdata-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 likeTT-<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"tottq.methods, callttq.holdConsent()beforettq.load(...), and callttq.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.
- 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
- 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.
- 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. - Check the banner’s mode and regions. For EU visitors the banner must ask first (opt-in), not just show a notice.
- 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
- 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
_ttporttclidcookies yet. - Click “Accept”: a page view request leaves within a few seconds, on the same page.
- In a fresh private window, click “Reject”: no page view or conversion events.
- 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
- TikTok Business Help Center, How to use cookies with TikTok Pixel (consents, CMP or the pixel’s consent mode): https://ads.tiktok.com/resources/help/article/how-to-use-cookies-with-tiktok-pixel?lang=en
- TikTok Business Help Center, Using cookies with TikTok Pixel (
_ttp,ttclid,ttcsidare advertising cookies): https://ads.tiktok.com/resources/help/article/using-cookies-with-tiktok-pixel?lang=en - TikTok API for Business, Pixel Cookie consent mode (
ttq.methods,holdConsentbeforettq.load,grantConsent): https://business-api.tiktok.com/portal/docs?id=1795929012554754 - TikTok API for Business, Work with Single Page Applications (GTM base-code tag name): https://business-api.tiktok.com/portal/docs?id=1801524003169281
- WordPress.org, TikTok (official plugin, no consent setting described): https://wordpress.org/plugins/tiktok-for-business/
- WooCommerce, TikTok for WooCommerce documentation (Marketing > TikTok): https://woocommerce.com/document/tiktok-for-woocommerce/
- TikTok plugin source, version 1.4.2 (inline scripts,
tiktok_ttclidset on the server, server-side Events API calls, no consent check): https://plugins.svn.wordpress.org/tiktok-for-business/trunk/pixel/Tt4b_Pixel_Class.php - TikTok plugin source, admin menu (TikTok menu on sites without WooCommerce): https://plugins.svn.wordpress.org/tiktok-for-business/trunk/admin/Tt4b_Menu_Class.php
- WordPress.org, WP Consent API (shares consent, does not block scripts): https://wordpress.org/plugins/wp-consent-api/
- Complianz plugin source, wizard Services step and TikTok in the social media list: https://plugins.svn.wordpress.org/complianz-gdpr/trunk/settings/config/fields/wizard/services.php and https://plugins.svn.wordpress.org/complianz-gdpr/trunk/config/class-config.php
- Complianz plugin source, TikTok integration (scripts containing
tiktok.com, marketing): https://plugins.svn.wordpress.org/complianz-gdpr/trunk/integrations/services/tiktok.php - Complianz, Integrations: Script Center, Plugins & Services: https://complianz.io/help/wordpress/configuration/integrating-plugins/
- Complianz, Does Complianz work with caching plugins?: https://complianz.io/help/wordpress/configuration/does-complianz-work-with-caching-plugins/
- CookieYes, How to implement prior consent (Cookie Manager, script URL pattern): https://www.cookieyes.com/documentation/implement-prior-consent-using-cookieyes/
- Cookiebot, Manual implementation (
type="text/plain",data-cookieconsent): https://www.cookiebot.com/en/manual-implementation/ - Cookiebot plugin source, list of add-ons (none for TikTok’s plugin): https://plugins.svn.wordpress.org/cookiebot/trunk/src/addons/controller/addons/
- PixelYourSite, TikTok Tag and API (part of PixelYourSite Pro): https://www.pixelyoursite.com/tiktok-tag-pixelyoursite
- PixelYourSite, ConsentMagic and other WordPress consent plugins (TikTok category usually marketing): https://www.pixelyoursite.com/docs/consentmagic-integration
- WordPress.org, Pixel Manager for WooCommerce (changelog 1.70.0): https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/
- WPCode, How to add header and footer code in WordPress: https://wpcode.com/how-to-add-header-and-footer-code-in-wordpress/
- Elementor, Add Facebook Pixel to Elementor (Custom Code): https://elementor.com/help/how-to-add-facebook-pixel-to-elementor/
- Elegant Themes, How to use the Divi Integration tab: https://help.elegantthemes.com/en/articles/2734187-how-to-use-the-divi-integration-tab
- Google Tag Manager Help, Tag Manager consent mode support: https://support.google.com/tagmanager/answer/10718549
- TikTok Business Help Center, TikTok Pixel Helper: https://ads.tiktok.com/resources/help/article/tiktok-pixel-helper-2.0?lang=en