How do you install a visitor ID tag on WordPress?
First, check which WordPress you have. On WordPress.com, the hosted service, JavaScript works only on a plugin-enabled plan with hosting features activated; free sites cannot add it. On self-hosted WordPress (WordPress.org software on your own hosting) there is no plan gate. Add the tag from a small plugin or a child theme, or use a header-and-footer plugin.
The problem most specific to WordPress comes after the install: speed plugins that delay JavaScript until the visitor moves the mouse, scrolls or taps. Some visitors read a page and leave without doing any of those. For them the tag never runs, and those visits are never recorded.
Is your site WordPress.com or self-hosted?
If you log in at wordpress.com and your plan appears there, it is WordPress.com. If you log in at yoursite.com/wp-admin on hosting you pay for separately, it is self-hosted. The two share the editor but not the rules for code.
How do you add the tag on WordPress.com?
Where it goes: Install a header-and-footer code plugin, or add the code to a child theme. Both need a plugin-enabled plan with hosting features activated.
Plan: A plugin-enabled plan with hosting features turned on. WordPress.com's support page says JavaScript works only there; free sites have limits on the code you can add. Plan names change, so check the current plan page before you buy.
What breaks it on WordPress.com
- A Custom HTML block puts code on one page only. Even on a plan where it can hold JavaScript, it is the wrong place for a tag that must be on every page.
- If the tag is missing after you upgrade, check that hosting features are turned on. The plan alone is not enough.
How to check it on WordPress.com
Log out (or use a private window), open two pages, and search each page's source for the vendor's host.
Source: WordPress.com Support: Add code to your site (read 2026-09-25).
How do you add the tag on self-hosted WordPress?
Where it goes: Register the vendor's script with wp_enqueue_script() in a function hooked to wp_enqueue_scripts, in a small site-specific plugin or a child theme's functions.php. Set the last argument to false to load it in <head>. This relies on the theme calling wp_head() and wp_footer(), as standard themes do. If the vendor gives you an inline snippet rather than a script URL, a header-and-footer plugin that pastes it into <head> is the simpler route.
What breaks it on self-hosted WordPress
- Do not edit the parent theme's
functions.php. WordPress's theme handbook warns that a theme update overwrites your changes. Use a child theme or a plugin. - Speed plugins can delay the tag. WP Rocket's "Delay JavaScript execution" postpones loading JavaScript "until there is a user interaction", and other speed plugins have similar options. Exclude the vendor's script: WP Rocket accepts a URL or keyword in its exclusion list, or a
nowprocketattribute on the tag. - Page caching serves the old HTML until the cache is cleared. Purge it after adding the tag.
- Script combining or minifying can rewrite the vendor's file. If it errors after optimization, exclude it there too.
How to check it on self-hosted WordPress
In a private window, load a page and do not touch it. If the vendor's request only appears after you move the mouse, a delay setting is holding it back. Then purge caches and check two page types, such as a post and the pricing page.
Sources: WordPress Developer Reference: wp_enqueue_script() (read 2026-09-25); WordPress Theme Handbook: Child themes (read 2026-09-25); WP Rocket Docs: Delay JavaScript execution (read 2026-09-25).
Where to go next
- Install through Google Tag Manager: if the site already runs a GTM container, add the tag there instead
- Consent decision tree: if a cookie plugin should hold the tag until consent
- Post-launch QA test script: the checks after the tag fires