WordPress
Paste one script into your WordPress header and Databuddy records every pageview and visit.
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
crossorigin="anonymous"
async
></script>Your Client ID is in the dashboard under your website's Settings → General.
Add the script
Check it works
Open your website in a private window and visit two or three pages. In the browser's Network tab, databuddy.js loads from cdn.databuddy.cc and events go to basket.databuddy.cc. Those visits then show on your dashboard.
Count form submissions
Count a contact form only when it succeeds. Contact Form 7 fires wpcf7mailsent after it sends the mail:
<script>
document.addEventListener("wpcf7mailsent", function (event) {
window.databuddy?.track("quote_request_completed", {
form_id: String(event.detail.contactFormId),
});
});
</script>Keep names, emails and messages out of event properties. Gravity Forms and WPForms have their own success hooks that work the same way.
Track button clicks
Add data-track-attributes to the script tag, then name any element in your content:
<a href="/contact" data-track="cta_click" data-cta-type="contact">Get a quote</a>Each click sends a cta_click event with ctaType: "contact". Every other data-* attribute on the element becomes a property the same way.
On a multisite network, add the script to each website with its own Client ID.
Related
How is this guide?