Tracking with Segment
Learn how to set up your Bucket tracking using Segment.io
In order to get started quickly with the full set of tracking and customer satisfaction collection in your app, we recommend always to use browser tracking. This can be done by enabling the Bucket Web (Actions) destination
Set up browser tracking (recommended)
Tracking in the browser through Segment Analytics.js can be done by using the Bucket Web (Actions) destination. It loads the Bucket Tracking SDK for you and automatically enables Live Satisfaction for immediate customer feedback.
-
Set up Bucket Web (Actions) destination to receive data from a Segment website source
-
Copy your Bucket App tracking key from the "Tracking" page and add it to the "Tracking Key" settings field in the destination
Bucket tracking page Segment destination settings → -
If you are using strict Content Security Policies, follow the instructions about Content Security Policy setup
-
Enable the destination
-
Check your Bucket Tracking page for data to arrive. This can take a while because Segment caches your Analytics.js configuration. Check back in a while
Special case
If you are using both browser and server destinations from the same Segment source, you should also read Running both server and browser tracking
Set up server tracking
Tracking from your backend services can be done through Segment cloud destinations. For Bucket tracking, use Bucket Cloud Destination
-
Set up Bucket Cloud destination to receive data from a Segment source
-
Copy your Bucket App tracking key from the "Tracking" page and add it to the "API Key" settings field in the destination
Bucket tracking page Segment destination settings → -
Enable the destination
-
Check your Bucket Tracking page for data to arrive. Data should start flowing immediately
Live Satisfaction
Note that Live Satisfaction will not be enabled when using a cloud destination, as browser scripting is required for gathering customer feedback in your app UI
Running both server and browser tracking
If you are running both server tracking and browser tracking to the same Bucket app from the same Segment source, you will get duplicate events tracked. To avoid this, disable the mapping of Track Event
in the Bucket Web (Actions)
destination so your mapping looks like this:
Tracking page views
Bucket doesn't support the Segment analytics.page()
-call to track pages. If page views are important for you, you can convert page
events to track
events in the Bucket Web (Actions) destination like this:
- Go to the "Mappings" tab
- Press "New Mapping"
- Select the "Track Event" action
- In the "Select events to map and send" section, change the event type from
event
topage
- In the "Select mappings" section, change the
Event Name
mapping to send in the Segment eventsname
field. Optionally prefix it withPage:
or append withViewed
to be able to add a distinguishable pattern from your normal event names
Content Security Policies (CSP)
If you are running with strict Content Security Policies active on your website, you will need to enable these directives in order to use this destination:
Directive | Values | Module | Reason |
---|---|---|---|
script-src-elem | https://cdn.jsdelivr.net | bootstrap | Loads the Bucket tracking SDK from a CDN |
connect-src | https://tracking.bucket.co | tracking | Used for all tracking methods: analytics.identify() , analytics.group() and analytics.track() |
connect-src | https://livemessaging.bucket.co | live satisfaction | Server sent events from the Bucket Live Feedback service, which allows for automatically collecting feedback when a user used a feature. |
style-src | 'unsafe-inline' | feedback UI | The feedback UI is styled with inline styles. Not having this directive results unstyled HTML elements. |
As HTTP-header:
Content-Security-Policy: script-src-elem https://cdn.jsdelivr.net; connect-src https://livemessaging.bucket.co https://tracking.bucket.co; style-src 'unsafe-inline'
As <meta>
-tag:
<meta http-equiv="Content-Security-Policy" content="script-src-elem https://cdn.jsdelivr.net; connect-src https://livemessaging.bucket.co https://tracking.bucket.co; style-src 'unsafe-inline'">
Only in the browser
These Content Security Policy rules are only needed when using the browser-based destination Bucket Web (Actions), not when using the server-based destination Bucket Cloud.
Updated about 2 months ago
When you see your data flowing in from your tracking, it's time to set up features: