Integrations

WordPress

Add Databuddy's privacy-first analytics to your WordPress site without slowing it down. No cookies, fully GDPR compliant, with an under 30 KB script (still far smaller than Google Analytics).

Installation Methods

Choose the installation method that works best for your WordPress setup. If you're using WordPress.com (hosted), you'll need to use a plugin since direct theme editing isn't available. For self-hosted WordPress.org sites, you have more flexibility.

Using a Plugin (Recommended)

The safest and easiest way to add Databuddy to WordPress is using a plugin that allows you to inject scripts without modifying theme files. This works for both WordPress.com and self-hosted installations.

1

Install a Script Injection Plugin

Install a plugin like Insert Headers and Footers from the WordPress plugin directory. This plugin lets you add scripts to your site's header or footer without touching theme files.

2

Add Your Databuddy Script

In the plugin settings, paste your Databuddy tracking script in the header section:

html
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
async
></script>
3

Save and Verify

Save your changes and wait a few minutes, then check your Databuddy dashboard to confirm tracking is working.

Tip: If the script doesn't load in the header, try adding it to the footer section instead. Some WordPress configurations work better with scripts in the body.

Using functions.php

For self-hosted WordPress sites, you can add Databuddy directly through your theme's functions.php file. This method uses WordPress hooks, which is cleaner than editing HTML directly.

1

Access Your Theme Files

Navigate to Appearance > Theme File Editor in your WordPress dashboard. For safer editing, consider using FTP/SFTP or your hosting control panel's file manager instead.

2

Open functions.php

Open your active theme's functions.php file. Important: If you're using a parent theme, create a child theme first to prevent losing changes when the theme updates.

3

Add the Tracking Function

Add this code at the end of your functions.php file:

functions.phpphp
function add_databuddy_analytics() {
?>
<script
  src="https://cdn.databuddy.cc/databuddy.js"
  data-client-id="YOUR_CLIENT_ID"
  async
></script>
<?php
}
add_action('wp_head', 'add_databuddy_analytics');

Replace YOUR_CLIENT_ID with your actual Client ID from your Databuddy dashboard.

4

Save and Test

Save the file and visit your site. Check the browser console for any errors and verify tracking in your Databuddy dashboard.

Using header.php

You can also add the script directly to your theme's header.php file. This method works but is less flexible than using functions.php since it requires direct HTML editing.

1

Access Theme Editor

Go to Appearance > Theme File Editor and select header.php. Again, using FTP or a file manager is safer if you're not comfortable editing files directly.

2

Find the Closing Head Tag

Locate the closing </head> tag in your header.php file. You'll add the script just before this tag.

3

Insert the Script

Add your Databuddy script right before </head>:

header.phphtml
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
async
></script>
</head>
4

Save Changes

Save the file and test your site. Remember to replace YOUR_CLIENT_ID with your actual Client ID.

Configuration Options

Basic Tracking Setup

Enable essential tracking features for most WordPress sites:

html
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
data-track-hash-changes
async
></script>

Enhanced Tracking Setup

For more detailed analytics, enable additional tracking options:

html
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
data-track-attributes
data-track-outgoing-links
data-track-interactions
data-track-performance
data-track-web-vitals
data-track-errors
async
></script>

WordPress-Specific Integrations

Form Submission Tracking

Track submissions from popular WordPress form plugins using data attributes:

html
<!-- Contact Form 7 -->
<input type="hidden" data-track="form_submit" data-form-type="contact">

<!-- Gravity Forms -->
<input type="hidden" data-track="form_submit" data-form-type="gravity">

<!-- WPForms -->
<input type="hidden" data-track="form_submit" data-form-type="wpforms">

Custom Post Type Analytics

Track views of custom post types by adding this to your theme's functions.php:

functions.phpphp
function track_custom_post_types() {
if (is_singular('your_custom_post_type')) {
  echo '<script>
    if (window.databuddy) {
      databuddy.track("custom_post_view", {
        post_type: "' . esc_js(get_post_type()) . '",
        post_id: ' . get_the_ID() . '
      });
    }
  </script>';
}
}
add_action('wp_footer', 'track_custom_post_types');

Performance Benefits

Databuddy is designed to have minimal impact on your WordPress site's performance:

  • Lightweight: Under 30 KB script size (far smaller than Google Analytics)
  • Non-blocking: Loads asynchronously without affecting page speed
  • Core Web Vitals: Improves your WordPress performance scores
  • Server Friendly: Minimal server load compared to other analytics solutions

Common Use Cases

Membership Sites

Track premium content engagement:

html
<button 
data-track="premium_content_view" 
data-content-type="video"
>
Watch Premium Video
</button>

Blog Analytics

Track article engagement and reading patterns:

html
<article 
data-track="article_view" 
data-category="tutorials" 
data-author="author-name"
>
<!-- Your article content -->
</article>

Lead Generation

Track conversion events and CTA clicks:

html
<a 
href="/contact" 
data-track="cta_click" 
data-cta-type="contact"
>
Get Quote
</a>

Troubleshooting

Script Not Loading

If Databuddy isn't tracking:

  1. Check Browser Console: Open developer tools and look for errors or the "Databuddy initialized" message
  2. Verify Script Placement: Ensure the script is in the <head> or before </body>
  3. Clear Cache: Clear your WordPress cache (WP Rocket, W3 Total Cache, etc.) and browser cache
  4. Test in Incognito: Use incognito/private browsing to avoid cache issues

Plugin Conflicts

If you're experiencing issues:

  • Temporarily deactivate other analytics plugins to identify conflicts
  • Check if your security plugin is blocking the script
  • Verify your theme includes wp_head() in header.php if using the functions.php method

Verification

After installation, verify tracking is working:

  1. Visit your site and navigate through a few pages
  2. Wait 2-3 minutes for data to process
  3. Check your Databuddy dashboard for page views
  4. Use browser dev tools Network tab to confirm requests are being sent

WordPress Multisite

For WordPress multisite networks:

  1. Individual Site Configuration: Add the Databuddy script to each site individually using one of the methods above
  2. Unique Client IDs: Each site should have its own Client ID for separate analytics
  3. Plugin Management: Consider using the Insert Headers and Footers plugin for easier management across multiple sites

Need help with your WordPress integration? Contact us at help@databuddy.cc.

How is this guide?