Wix
Add Databuddy's privacy-first analytics to your Wix website to track page views, user interactions, and gather insights about your visitors.
How to Add Databuddy to Wix
Get Your Tracking Script
Get your Databuddy tracking script from your Databuddy dashboard. It will look like this:
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
async
></script>Replace YOUR_CLIENT_ID with your actual Client ID from your Databuddy dashboard.
Go to Wix Dashboard
Log in to your Wix account and select the site you want to track.
From your site's dashboard, navigate to Settings (usually in the left-hand sidebar).
Access Tracking Tools
In the Settings menu, look for a section related to tracking or advanced settings. This is often called:
- Tracking Tools & Analytics (under "Marketing & SEO" or a similar category)
- Or, Custom Code (sometimes under "Advanced Settings")
To add custom code, you'll need a Wix Premium plan and a connected domain. This feature is typically not available on free Wix plans.
Add New Custom Code
Once in the Tracking Tools or Custom Code section:
- Click on + New Tool or + Add Custom Code
- Choose Custom from the list of options if prompted
Configure the Custom Code
You'll be presented with a form to add your code:
- Paste your Databuddy tracking script into the main code snippet box
- Name your code: Give it a recognizable name, like "Databuddy Analytics"
- Add Code to Pages: Select All pages to track your entire site
- You might have an option to Load code once or Load code on each new page. Choose the option that loads the script on every page view
- Place Code in: Choose Body - end. This is recommended for analytics scripts to avoid impacting perceived page load speed. Some Wix versions might offer "Head" or "Body - start" as well. "Body - end" is usually the best choice
Apply Changes
Click Apply or Save to add the custom code to your site.
Verify Integration
After applying the changes, Databuddy should start tracking visitors on your Wix site.
- Open your Wix website in a new browser tab or incognito window
- Navigate through a few pages
- Check your Databuddy dashboard for incoming data. It might take a few minutes for the first events to appear
Configuration Options
Enable additional tracking features by adding data attributes to your script tag:
<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
data-track-scroll-depth
async
></script>Custom Event Tracking in Wix
Track custom events in Wix by adding JavaScript code through the Custom Code section or using Wix's built-in code elements.
Using Data Attributes
Enable automatic tracking with data attributes:
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
data-track-attributes
async
></script>Then add data-track attributes directly to elements in Wix:
<!-- Button with automatic tracking -->
<button data-track="cta_click" data-button-type="primary">
Get Started
</button>
<!-- Link with tracking -->
<a href="/pricing" data-track="pricing_link_click" data-link-location="header">
View Pricing
</a>Tracking Button Clicks with Custom Code
Add custom JavaScript to track specific button interactions:
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
// Wait for Wix to fully load
setTimeout(function() {
var button = document.getElementById('your-button-id');
if (button && window.databuddy) {
button.addEventListener('click', function() {
window.databuddy.track('button_click', {
button_id: 'your-button-id',
button_text: button.textContent || button.innerText,
page_path: window.location.pathname
});
});
}
}, 1000); // Adjust delay if needed for Wix to initialize
});
</script>Tracking Form Submissions
Track form submissions from Wix forms:
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
var form = document.querySelector('form[data-name="ContactForm"]');
if (form && window.databuddy) {
form.addEventListener('submit', function() {
window.databuddy.track('form_submit', {
form_type: 'contact',
page_path: window.location.pathname
});
});
}
}, 1000);
});
</script>Important Notes:
- Wix may require a Premium plan to add custom code
- Use
setTimeoutto ensure Wix has fully loaded before attaching event listeners - Always check if
window.databuddyexists before calling tracking methods - Test thoroughly as Wix's page structure may vary
Common Use Cases
E-commerce Tracking
Track product views and purchases:
// Track product view
if (window.databuddy) {
window.databuddy.track('product_view', {
product_id: 'product-123',
product_name: 'Example Product',
price: 29.99
});
}
// Track add to cart
window.databuddy.track('add_to_cart', {
product_id: 'product-123',
quantity: 1
});Newsletter Signups
Track newsletter subscriptions:
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
var newsletterForm = document.querySelector('form[data-name="NewsletterForm"]');
if (newsletterForm && window.databuddy) {
newsletterForm.addEventListener('submit', function() {
window.databuddy.track('newsletter_signup', {
form_location: 'footer',
page_path: window.location.pathname
});
});
}
}, 1000);
});Troubleshooting
Script Not Loading
- Verify the script is in the Body - end section of Custom Code
- Check browser console for errors
- Ensure your Client ID is correct
- Confirm you have a Wix Premium plan with custom code enabled
Events Not Tracking
- Confirm
window.databuddyexists before calling tracking methods - Use
setTimeoutto wait for Wix to fully initialize - Check that elements exist before attaching event listeners
- Verify events appear in your Databuddy dashboard after 2-3 minutes
Wix-Specific Issues
- Wix may load pages dynamically, so ensure scripts run after page load
- Some Wix elements may have dynamically generated IDs
- Test in different browsers and devices
- Clear Wix cache and republish your site if needed
Need help with your Wix integration? Contact us at help@databuddy.cc.
How is this guide?