Back to Installation

WordPress Installation Guide

Step-by-step guide to install TwoBucks Analytics on WordPress.

Quick Start

Method 1: Header/Footer Plugin (Recommended)

  1. Install a header/footer plugin like "Insert Headers and Footers"
  2. Go to Settings → Insert Headers and Footers
  3. Add the script to the Header section:
<script
  src="https://twobucks.ai/script.js"
  data-website-id="your-website-id"
  async
></script>

Method 2: Theme Functions.php

Add to your theme's functions.php:

// functions.php
function twobucks_analytics() {
    ?>
    <script
      src="https://twobucks.ai/script.js"
      data-website-id="your-website-id"
      async
    ></script>
    <?php
}
add_action('wp_head', 'twobucks_analytics');

Method 3: Theme Header Template

Edit header.php in your theme:

<!-- header.php -->
<head>
  <!-- Other head content -->
  <script
    src="https://twobucks.ai/script.js"
    data-website-id="your-website-id"
    async
  ></script>
</head>

WooCommerce Integration

Track WooCommerce events:

// functions.php
// Track add to cart
add_action('woocommerce_add_to_cart', function($cart_item_key, $product_id) {
    ?>
    <script>
    if (window.twobucks) {
        window.twobucks('add_to_cart', {
            product_id: '<?php echo esc_js($product_id); ?>'
        });
    }
    </script>
    <?php
}, 10, 2);

// Track purchase
add_action('woocommerce_thankyou', function($order_id) {
    $order = wc_get_order($order_id);
    ?>
    <script>
    if (window.twobucks) {
        window.twobucks('purchase', {
            order_id: '<?php echo esc_js($order_id); ?>',
            total: '<?php echo esc_js($order->get_total()); ?>'
        });
    }
    </script>
    <?php
});

Common Issues

Script Not Loading

  1. Check that your theme supports wp_head hook
  2. Verify script is added to <head> section
  3. Check browser console for errors

Caching

If using caching plugins (WP Super Cache, W3 Total Cache, etc.):

  1. Clear cache after adding script
  2. Ensure script is not excluded from cache
  3. Check that script loads on cached pages

Multisite

For WordPress Multisite, add script to network admin or individual site settings.

Next Steps