WordPress Integration

Add qvctrs to WordPress using the theme customizer, a plugin, or by editing your theme files directly.

Easy3 minutes

Method 1: Theme Customizer (Easiest)

Many WordPress themes have a built-in option to add custom scripts.

  1. Go to Appearance → Customize
  2. Look for "Additional CSS/JS", "Custom Scripts", or similar
  3. Find the "Header Scripts" field
  4. Paste the qvctrs snippet:
<script>
window.qvctrs=window.qvctrs||{};window.qvctrs.q=window.qvctrs.q||[];
window.qvctrs.init=window.qvctrs.init||function(){window.qvctrs.q.push(['init'].concat(Array.prototype.slice.call(arguments)))};
window.qvctrs.init({siteId:'YOUR_SITE_ID'});
</script>
<script src="https://www.qvctrs.com/qvctrs-sdk-v2.js" async></script>
  1. Click Publish

Method 2: Header/Footer Plugin

If your theme doesn't have script options, use a plugin.

Recommended plugins:

  • Insert Headers and Footers by WPBeginner
  • Header Footer Code Manager
  • WPCode (formerly Insert Headers and Footers)

Steps:

  1. Install and activate one of the above plugins
  2. Go to Settings → Insert Headers and Footers (or similar)
  3. Paste the qvctrs snippet in the Header section
  4. Save changes

Method 3: Edit Theme Files

Use a Child Theme

Always edit a child theme to prevent losing changes on theme updates.

Option A: header.php

  1. Go to Appearance → Theme File Editor
  2. Select header.php from the right sidebar
  3. Find the </head> tag
  4. Paste the snippet just before it:
<!-- qvctrs SDK -->
<script>
window.qvctrs=window.qvctrs||{};window.qvctrs.q=window.qvctrs.q||[];
window.qvctrs.init=window.qvctrs.init||function(){window.qvctrs.q.push(['init'].concat(Array.prototype.slice.call(arguments)))};
window.qvctrs.init({siteId:'YOUR_SITE_ID'});
</script>
<script src="https://www.qvctrs.com/qvctrs-sdk-v2.js" async></script>
</head>

Option B: functions.php

Use WordPress hooks for cleaner integration:

// Add to functions.php or a custom plugin

function add_qvctrs_sdk() {
    ?>
    <script>
    window.qvctrs=window.qvctrs||{};window.qvctrs.q=window.qvctrs.q||[];
    window.qvctrs.init=window.qvctrs.init||function(){window.qvctrs.q.push(['init'].concat(Array.prototype.slice.call(arguments)))};
    window.qvctrs.init({siteId:'YOUR_SITE_ID'});
    </script>
    <script src="https://www.qvctrs.com/qvctrs-sdk-v2.js" async></script>
    <?php
}
add_action('wp_head', 'add_qvctrs_sdk');

Method 4: Using wp_enqueue_script

For developers who prefer WordPress best practices:

// Add to functions.php

function enqueue_qvctrs_sdk() {
    // Add inline shim first
    wp_add_inline_script(
        'qvctrs-shim',
        "window.qvctrs=window.qvctrs||{};window.qvctrs.q=window.qvctrs.q||[];" .
        "window.qvctrs.init=window.qvctrs.init||function(){window.qvctrs.q.push(['init'].concat(Array.prototype.slice.call(arguments)))};" .
        "window.qvctrs.init({siteId:'YOUR_SITE_ID'});"
    );

    // Enqueue the SDK
    wp_enqueue_script(
        'qvctrs-sdk',
        'https://www.qvctrs.com/qvctrs-sdk-v2.js',
        array(),
        '2.4.0',
        false // Load in head
    );

    // Add async attribute
    add_filter('script_loader_tag', function($tag, $handle) {
        if ('qvctrs-sdk' === $handle) {
            return str_replace(' src', ' async src', $tag);
        }
        return $tag;
    }, 10, 2);
}
add_action('wp_enqueue_scripts', 'enqueue_qvctrs_sdk');

WooCommerce

For WooCommerce stores, use any of the methods above. The qvctrs SDK automatically captures e-commerce behaviors like:

  • Product browsing and comparison patterns
  • Add to cart hesitations
  • Checkout form interactions
  • Cart abandonment signals

Verify Installation

  1. Clear any caching plugins (WP Rocket, W3 Total Cache, etc.)
  2. Visit your site in an incognito window
  3. Open Developer Tools → Console
  4. Run window.qvctrs.version — should show "2.4.0"

Checklist

  • Snippet added via customizer, plugin, or theme file
  • Site ID replaced with your actual ID
  • Cache cleared
  • Verified in browser console

Troubleshooting

Script not loading

  • Check if a security plugin is blocking external scripts
  • Verify the script isn't being minified/combined incorrectly
  • Clear all caches (browser, plugin, CDN)

Conflicts with other plugins

The qvctrs SDK is designed to be non-intrusive and shouldn't conflict with other plugins. If you experience issues, check the browser console for errors.