Trackthemetric Logo

Trackthemetric + WordPress

Follow these steps to integrate Trackthemetric analytics into your WordPress site. Choose the plugin method if you prefer a simple, update-safe setup; use the header.php method only if you know your theme structure well.

Option 1
Use a plugin to add the script (Recommended)

This is the easiest and safest way to add the tracking script to all pages.

1. In your WordPress admin, go to Plugins Add New and install a plugin that lets you insert code into the site header, e.g. Insert Headers and Footers or WPCode.

2. Open the plugin's settings (usually under Settings or Tools) and find the field for Scripts in Header.

3. Paste the following snippet:

<script
  defer
  id="TrackTheMetric"
  data-website-id="YOUR_WEBSITE_ID"
  data-domain="YOUR_DOMAIN.COM"
  src="https://app.trackthemetric.com/tracker.js"
></script>

Replace the YOUR_WEBSITE_ID and YOUR_DOMAIN.COM with your actual website ID and root domain.

4. Save changes. Visit a few pages on your live site to start sending events.

Option 2
Edit your theme's header.php (Advanced)

If you prefer not to use a plugin, you can add the snippet directly to your active theme. Consider using a child theme so updates don't overwrite your changes.

1. In the WordPress admin, go to Appearance Theme File Editor.

2. Select your active theme and open the header.php file.

3. Paste the snippet just before the closing </head> tag:

<!-- Place just before the closing </head> tag in header.php -->
<script
  defer
  id="TrackTheMetric"
  data-website-id="YOUR_WEBSITE_ID"
  data-domain="YOUR_DOMAIN.COM"
  src="https://app.trackthemetric.com/tracker.js"
></script>

Changes made directly to a parent theme may be overwritten by theme updates. Use a child theme or a site-specific plugin to keep customizations persistent.

Replace the YOUR_WEBSITE_ID and YOUR_DOMAIN.COM with your actual website ID and domain.

4. Click Update File and clear any caching layer (plugins/CDN) if enabled.

3
Verify the installation

After implementing either method:

  • Visit your live website and browse a couple of pages.
  • Open your Trackthemetric dashboard.
  • Within a few minutes, new pageviews should appear.