Skip to main content

Attach custom properties to pageviews

Using WordPress?

The quickest way to start tracking custom properties is to use our official WordPress plugin

Add your custom properties to your bahtu snippet

You can add custom properties by updating your bahtu snippet.

To add properties that attach to every tracked event, update the bahtu.init call to pass customProperties option:

bahtu.init({
// ... Other initialization options
customProperties: {
author: "John Doe",
type: "blog-post"
}
})

You're now tracking custom properties alongside pageviews.

Advanced: Dynamically setting custom properties

To include dynamic data for custom properties, set customProperties to be a function. This function will be called for every event.

For example:

bahtu.init({
// ... Other initialization options
customProperties: function(eventName) {
if (eventName == "pageview") {
return {
author: "John Doe",
title: document.title
}
}

return {}
}
})

Haven't tried bahtu yet? Start a free trial or view the live demo.