Back to Installation
WordPress Installation Guide
Step-by-step guide to install TwoBucks Analytics on WordPress.
Quick Start
Method 1: Header/Footer Plugin (Recommended)
- Install a header/footer plugin like "Insert Headers and Footers"
- Go to Settings → Insert Headers and Footers
- 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
- Check that your theme supports
wp_headhook - Verify script is added to
<head>section - Check browser console for errors
Caching
If using caching plugins (WP Super Cache, W3 Total Cache, etc.):
- Clear cache after adding script
- Ensure script is not excluded from cache
- Check that script loads on cached pages
Multisite
For WordPress Multisite, add script to network admin or individual site settings.