InstallPlatforms
WordPress
Add trckable to a WordPress site with a header-scripts plugin or your child theme, without losing it on the next theme update.
The easiest way is a plugin that adds code to your site's head. Editing the theme directly works, but a theme update overwrites it.
Steps
- In the WordPress admin, go to Plugins → Add New Plugin and install WPCode (or Insert Headers and Footers), then activate it.
- Open the plugin's header settings (in WPCode: Code Snippets → Header & Footer).
- Paste the script tag below into the Header box.
- Click Save Changes.
<script
defer
data-site="tkb_a1b2c3d4"
data-domain="example.com"
src="https://stats.example.com/js/tkb_a1b2c3d4.js">
</script>Prefer code? Put this in the functions.php of a child theme instead of using a plugin. Do not paste it into the parent theme: an update removes it.
<?php // functions.php of your child theme
add_action('wp_head', function () { ?>
<script
defer
data-site="tkb_a1b2c3d4"
data-domain="example.com"
src="https://stats.example.com/js/tkb_a1b2c3d4.js">
</script>
<?php });Check it works
Open your site in a private window, then open your trckable dashboard and look at Live. Your visit shows up within a minute.
If it does not show
- A caching or optimisation plugin (WP Rocket, LiteSpeed, Autoptimize) can serve an old page or delay the script. Clear its cache, and exclude the script from delay or minify settings.
- A theme without a
wp_head()call inheader.phpprints no head code. Most themes have it; if yours does not, use a different theme or ask its author. - Block themes and page builders sometimes set their own head. The plugin route above still works with them.
Still stuck? Run npx trckable doctor against your site, or see the script tag page.