Ours Integration with WordPress

Learn how to integrate Ours with your WordPress website for tracking page views and custom events seamlessly.

Ours Integration with WordPress

This guide will walk you through integrating Ours with your WordPress website. You’ll learn how to install the Ours tracking script, track page views, and log custom events—all while ensuring HIPAA-compliant analytics for privacy-conscious applications.

Integration Options

The integration guide below covers using the Ours Privacy Web SDK.

If you want to use Google Tag Manager instead, you can ignore the code examples and use traditional Google Tag Manager Triggers to fire your events.

Choose the approach that best suits your workflow.


Install

To integrate Ours with your WordPress website, you’ll need to install the Ours tracking script. Follow these steps:

  1. Go to the Install Ours page in your Ours account.
  2. Copy the script provided on that page.
  3. Add the script to your WordPress site using one of these methods:
    • Using a Plugin: We recommend using a plugin such as Insert Headers and Footers or Code Snippets.
      • Paste the script into the Header section of the plugin settings.
    • Directly in the Theme:
      • Navigate to Appearance > Theme Editor in your WordPress admin dashboard.
      • Open the header.php file of your active theme.
      • Paste the script just before the closing </head> tag.

Save your changes and verify the script is included on all pages of your website.


Tracking Page Views

By default, Ours does not automatically track page views. You need to explicitly track them by adding the following line after theours('init', ...) call in the script:

<!-- Ours Pixel Code -->
<script>
 // your install code is here


 ours('track', 'PageView');
</script>
<!-- End Ours Pixel Code -->

This ensures page views are logged correctly in Ours.


Track Events

To track custom events such as form submissions or button clicks, you can add the ours('track', ...) function in your WordPress code or using custom JavaScript. You can place this in the plugin settings (if using a plugin like Insert Headers and Footers) or directly within your site’s JavaScript files.

Example: Tracking Button Clicks

<button onclick="ours('track', 'ButtonClicked');">Contact Us</button>

Example: Tracking Form Submissions

<form onsubmit="ours('track', 'FormSubmit');">
  <input type="text" name="name" placeholder="Your Name" />
  <button type="submit">Submit</button>
</form>

Recommended Plugins

Here are some WordPress plugins that make it easy to add the Ours tracking script and manage events:

  1. Insert Headers and Footers: A simple plugin for adding custom scripts to your site.
  2. Code Snippets: A versatile plugin for adding custom JavaScript and PHP snippets to your site.

Why Use Ours for WordPress?

Ours is a great choice for integrating HIPAA-compliant analytics into your WordPress site. It helps you track user interactions while maintaining privacy and security.

Key Benefits:

  • HIPAA Compliance: Built for healthcare and privacy-conscious organizations.
  • Custom Event Flexibility: Easily track specific interactions like form submissions or button clicks.
  • No IP Exposure: Ours proxies events to ensure user privacy.

If you need further assistance, contact us at [email protected].