E-Commerce Platforms
Installing Scoby Analytics on WooCommerce
Like all Scoby integrations, this lightweight, client-side integration is carefully designed to prioritize visitor privacy. It fully complies with EU ePrivacy and GDPR regulations, while enabling you to exercise your legitimate interest in understanding how your website is being used.
Prerequisites
Before you start, make sure you have the following ready:
- A Scoby Analytics Workspace
- Your Workspace ID
- Administrator access to your WordPress / WooCommerce site
Installation Guide
You can install the Scoby Analytics snippet on WooCommerce in one of two ways:
- Using the “Code Snippets” plugin (recommended)
- By manually editing your theme’s
functions.php
file
Using the “Code Snippets” Plugin (Recommended)
In your WordPress Admin, go to Plugins → Add New and install the Code Snippets plugin if not already installed.
Navigate to Snippets → Add New.
Give your snippet a name, for example:
Scoby Analytics
.Copy and paste the following code into the Code field.
Replace<WORKSPACE_ID>
with your actual Workspace ID from Step 1.
<?php
add_action('wp_head', function () {
?>
<script>
(function () {
const workspaceId = "<WORKSPACE_ID>";
window.scoby = window.scoby || function () {
(window.scoby.q = window.scoby.q || []).push(arguments);
};
window.scoby('init', { autoLogging: false });
// Log page views
document.addEventListener('DOMContentLoaded', function () {
const url = window.location.href;
const referrer = document.referrer;
window.scoby('logPageView', { url, referrer });
});
// Log WooCommerce order completions
document.addEventListener('DOMContentLoaded', function () {
if (window.location.href.indexOf('/order-received/') !== -1) {
// Extract order data from WooCommerce thank you page
const amountEl = document.querySelector('.woocommerce-order-overview__total .woocommerce-Price-amount bdi');
const currencyEl = document.querySelector('.woocommerce-order-overview__total .woocommerce-Price-currencySymbol');
if (amountEl) {
const amount = amountEl.textContent.replace(/[^\d.,]/g, '');
const currency = currencyEl ? currencyEl.textContent : '';
const goal = "Purchase";
window.scoby('logConversion', { goal, amount, currency });
}
}
});
// Load Scoby script
const script = document.createElement('script');
script.src = `https://${workspaceId}.s3y.io`;
document.head.append(script);
})();
</script>
<?php
});
?>
- Choose “Run snippet everywhere”, then click Save Changes and Activate.
Editing functions.php
Directly
If you prefer not to use a plugin, you can paste the same code block (without the <?php ?>
wrapper) into your theme’s functions.php
file inside a wp_head
action. Make sure to place it in a child theme so it’s not overwritten by updates.
Done 🎉
Scoby Analytics is now collecting privacy-friendly, aggregated analytics data from your WooCommerce store — no cookies, no consent banner required for basic pageview and conversion logging under GDPR and ePrivacy.