Docs/Installation Guides/WordPress

WordPress Installation

Installing VersaTailor on your WordPress website can be done in several ways. Choose the method that works best for your setup and comfort level with WordPress.

Step 1: Get Your Tracking Script

  1. Log in to your VersaTailor dashboard
  2. Click on the website dropdown in the top navigation
  3. Select "Site Settings" from the dropdown menu
  4. In the General tab, copy your unique tracking script

Your tracking script will look like this:

<script
  defer
  src="https://versatailor.com/script.js"
  data-website-id="your-website-id-here"
  data-domain="yourdomain.com"
></script>

Method 1: Using WordPress Admin (Recommended)

The easiest way to install VersaTailor is through your WordPress admin dashboard:

  1. Log in to your WordPress admin dashboard
  2. Navigate to Appearance > Theme Editor
  3. Select your active theme
  4. Click on header.php from the file list
  5. Find the </head> closing tag
  6. Paste your VersaTailor tracking script just before the </head> tag
  7. Click Update File

⚠️ Important: Editing theme files directly means you'll lose your tracking script if you update your theme. Consider using a child theme or one of the alternative methods below.

Method 2: Using a Plugin (Safest)

Using a plugin ensures your tracking script won't be lost during theme updates:

Option A: Insert Headers and Footers Plugin
  1. Install the "Insert Headers and Footers" plugin from the WordPress plugin directory
  2. Activate the plugin
  3. Go to Settings > Insert Headers and Footers
  4. Paste your VersaTailor tracking script in the "Scripts in Header" section
  5. Click Save
Option B: Head, Footer and Post Injections Plugin
  1. Install the "Head, Footer and Post Injections" plugin
  2. Activate the plugin
  3. Go to Settings > Header and Footer
  4. Paste your tracking script in the "HEAD Page Section Injection" field
  5. Click Save Changes

Method 3: Using functions.php

For developers who prefer to add code to their theme's functions.php file:

// Add this to your theme's functions.php file
function add_versatailor_tracking() {
    ?>
    <script
      defer
      src="https://versatailor.com/script.js"
      data-website-id="your-website-id-here"
      data-domain="yourdomain.com"
    ></script>
    <?php
}
add_action('wp_head', 'add_versatailor_tracking');

Method 4: Using WordPress Customizer

Some themes support adding custom scripts through the WordPress Customizer:

  1. Go to Appearance > Customize
  2. Look for "Additional CSS" or "Custom Code" section
  3. If your theme supports it, you may find a "Header Scripts" or "Custom HTML" option
  4. Paste your VersaTailor tracking script there
  5. Click Publish

Step 3: Verify Installation

  1. Visit your WordPress website in a browser
  2. View the page source (Ctrl+U or Cmd+U)
  3. Search for "versatailor.com/script.js" to confirm the script is present
  4. Return to your VersaTailor dashboard
  5. Use the "Verify Installation" button in Site Settings
  6. Confirm that page views are being tracked

WooCommerce Integration

If you're running a WooCommerce store, you can track purchase events by adding this code to your theme's functions.php:

// Track WooCommerce purchases
function versatailor_track_purchase($order_id) {
    $order = wc_get_order($order_id);
    $total = $order->get_total() * 100; // Convert to cents
    $email = $order->get_billing_email();
    ?>
    <script>
    window?.versatailor("payment", {
        email: "<?php echo esc_js($email); ?>",
        amnt: <?php echo $total; ?>
    });
    </script>
    <?php
}
add_action('woocommerce_thankyou', 'versatailor_track_purchase');
🎉 You're All Set!

Your WordPress website is now tracking page views automatically. Visit your VersaTailor dashboard to see real-time analytics and visitor data.

Troubleshooting Tips
  • If the script isn't loading, check that there are no JavaScript errors in your browser's console
  • Ensure your VersaTailor script is placed in the <head> section, not the footer
  • Some caching plugins may require you to clear the cache after installation
  • If using a security plugin, make sure it's not blocking the VersaTailor script

⚠️ Important: Always make sure to replace your-website-id-here and yourdomain.com with your actual website ID and domain from the VersaTailor dashboard.

Need help? Contact us for assistance.

Suggest features? We'd love your feedback