Bubble.io
This guide explains how to integrate Databuddy with your Bubble.io application to track user behavior, page views, and custom events.
How to Add Databuddy to Your Bubble App
Bubble allows you to add custom code, including JavaScript snippets, to the header of your pages.
Get Your Tracking Script
Navigate to your Databuddy dashboard to get your tracking code snippet. It will look like this:
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
async
></script>Remember to replace YOUR_CLIENT_ID with your actual Client ID.
Access Your Bubble App Settings
Add the Snippet to the Page Header
Alternatively, some Bubble plans or configurations might offer a dedicated section for "Advanced Settings" or "Custom Code" where header scripts can be placed globally or on specific pages. The "SEO / metatags" header script section is generally the most common place for global scripts.
Deploy Your App
After adding the script, ensure you deploy your Bubble application to the live version for the changes to take effect.
Verify Installation
Open your live Bubble application and navigate through a few pages. Then, check your Databuddy dashboard to see if data is being received. You can also inspect your browser's network tab to confirm the script is loaded.
Custom Event Tracking in Bubble
Track custom events in Bubble by using a workflow action that runs JavaScript.
Create a Workflow
In the Bubble editor, go to the Workflow tab.
Create a new workflow triggered by the event you want to track (e.g., "When Button A is clicked", "When a user's data changes", "When a page is loaded" and a certain condition is met).
Add Run JavaScript Action
Within your workflow, add a new action.
Search for and select the "Run JavaScript" action (this might be provided by a free official Bubble plugin or a community plugin if not available by default; ensure you have a way to execute arbitrary JS).
Add Databuddy Tracking Code
In the "Run JavaScript" action's code block, add your Databuddy event tracking code:
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.track('bubble_event_name', {
// You can use Bubble's dynamic expressions here to pass data
// For example: 'User Email': Current User's Email,
// 'Clicked Element': This Button's Text (if applicable)
property1: 'value1',
property2: 'value2'
});
}Replace 'bubble_event_name' with a descriptive name for your event. You can use Bubble's dynamic data expressions within the JavaScript if the "Run JavaScript" action supports it, or pass data into the JavaScript action from previous workflow steps.
Example: If tracking a button click for a specific item:
// Assuming you can pass dynamic data to the JS action
// let itemName = "Dynamic Item Name from Bubble"; // This would be set by Bubble's dynamic data
// let itemCategory = "Dynamic Category from Bubble";
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.track('item_interaction', {
name: itemName, // Replace with actual dynamic data
category: itemCategory // Replace with actual dynamic data
});
}Test Your Event
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
async
></script>Common Use Cases
Tracking Button Clicks
Track when users click specific buttons:
// In Bubble's Run JavaScript action
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.track('button_click', {
button_id: 'cta-button',
button_text: 'Get Started',
page_path: window.location.pathname
});
}Tracking Form Submissions
Track form submissions:
// In Bubble's Run JavaScript action (triggered on form submit)
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.track('form_submit', {
form_type: 'contact',
form_id: 'contact-form',
page_path: window.location.pathname
});
}Tracking Virtual Page Views
Track "virtual" page views when groups are shown/hidden:
// In Bubble's Run JavaScript action (triggered when a group/page becomes visible)
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.screenView({
screen_name: 'dashboard',
screen_class: 'Bubble',
path: window.location.pathname
});
}Tracking User Actions
Track user interactions with dynamic data:
// Example: Track when a user views a product
// Pass dynamic data from Bubble workflow
if (typeof window !== 'undefined' && window.databuddy) {
window.databuddy.track('product_view', {
product_id: productId, // From Bubble's dynamic data
product_name: productName, // From Bubble's dynamic data
product_price: productPrice, // From Bubble's dynamic data
user_id: currentUser.id // From Bubble's Current User
});
}Using Data Attributes
Enable automatic tracking with data attributes by adding data-track-attributes to your script tag. Then add data-track attributes directly to elements in your Bubble app:
<!-- Enable data-track attributes in script tag -->
<script
src="https://cdn.databuddy.cc/databuddy.js"
data-client-id="YOUR_CLIENT_ID"
data-track-attributes
async
></script>
<!-- Then use in your Bubble app elements -->
<button data-track="cta_click" data-button-type="primary">
Get Started
</button>
<a href="/pricing" data-track="pricing_link_click" data-link-location="header">
View Pricing
</a>Troubleshooting
Script Not Loading
Events Not Tracking
Virtual Page Views Not Tracked
Dynamic Data Not Passing
Related Integrations
Need help with your Bubble.io integration? Contact us at help@databuddy.cc.
How is this guide?