WordPress

Install EngageTrack on your WordPress website.

WordPress

Add EngageTrack analytics to your WordPress site. No plugin required — just a single script tag added to your site's header.

Option A: Insert Headers and Footers Plugin (Easiest)

If you're not comfortable editing theme files, use a plugin to inject the script.

  1. Install and activate the WPCode plugin (formerly Insert Headers and Footers) from the WordPress plugin directory.
  2. Go to Code Snippets → Header & Footer in the WordPress admin.
  3. Paste the following into the Header section:
<script
	defer
	data-site-id="YOUR_SITE_ID"
	src="https://cdn.engagetrack.net/sdk.js"
></script>
  1. Click Save Changes.

Replace YOUR_SITE_ID with the Site ID from your EngageTrack dashboard (Site Settings → General).

Option B: Edit header.php

If you prefer not to install a plugin, add the script directly to your theme's header file.

  1. In the WordPress admin, go to Appearance → Theme File Editor.
  2. Select your active theme and open header.php.
  3. Find the closing </head> tag and add the script just above it:
<!-- EngageTrack Analytics -->
<script
	defer
	data-site-id="YOUR_SITE_ID"
	src="https://cdn.engagetrack.net/sdk.js"
></script>
</head>
  1. Click Update File.

Editing header.php directly means your changes will be lost when the theme updates. To avoid this, use a child theme or use the plugin approach (Option A) instead.

Option C: wp_enqueue_script in functions.php

For developers who prefer the WordPress way, add the script via functions.php:

// functions.php (in your child theme)
function engagetrack_enqueue_script() {
    wp_enqueue_script(
        'engagetrack',
        'https://cdn.engagetrack.net/sdk.js',
        array(),
        null,
        false // Load in header
    );
 
    // Add the data-site-id attribute
    wp_script_add_data('engagetrack', 'data-site-id', 'YOUR_SITE_ID');
}
add_action('wp_enqueue_scripts', 'engagetrack_enqueue_script');
 
// Add defer and data attributes to the script tag
function engagetrack_script_attributes($tag, $handle) {
    if ('engagetrack' !== $handle) {
        return $tag;
    }
    return str_replace(
        ' src=',
        ' defer data-site-id="YOUR_SITE_ID" src=',
        $tag
    );
}
add_filter('script_loader_tag', 'engagetrack_script_attributes', 10, 2);

Track Goals with HTML Attributes

You can track button clicks and link interactions across your WordPress site using data-goal attributes. This works in the WordPress block editor, page builders, and raw HTML:

<!-- In any post, page, or widget -->
<a href="/pricing" data-goal="pricing-clicked">View Pricing</a>
<button data-goal="newsletter-signup">Subscribe</button>

Most page builders (Elementor, Divi, Beaver Builder) let you add custom HTML attributes to elements. Look for an "Advanced" or "Attributes" section in the element settings.

WooCommerce Revenue Tracking

For WooCommerce stores, add a conversion tracking snippet to the order confirmation page. Add this to your child theme's functions.php:

function engagetrack_woocommerce_tracking($order_id) {
    $order = wc_get_order($order_id);
    if (!$order) return;
    ?>
    <script>
        if (window.engagetrack) {
            window.engagetrack.trackPurchase({
                revenue: <?php echo $order->get_total(); ?>,
                currency: '<?php echo $order->get_currency(); ?>'
            });
        }
    </script>
    <?php
}
add_action('woocommerce_thankyou', 'engagetrack_woocommerce_tracking');

Verify Installation

  1. Save your changes and visit your WordPress site.
  2. Navigate between a few pages.
  3. In the EngageTrack dashboard, go to the Realtime tab — your visits should appear within seconds.

If you see your pageviews in Realtime, you're all set. If not, add data-debug="true" to the script tag and check the browser console for diagnostic messages.