Google Cloud Pub/Sub Destination
- Accepts Page, Alias, Group, Identify, and Track calls
- Referred to as Google Cloud PubSub in the Integrations object
When you enable Google Cloud Pub/Sub in the Segment app, Segment starts sending the events you specify to Pub/Sub topics of your choice. The Segment Google Cloud Pub/Sub destination supports all of the Segment methods, and sends data from any of the Segment libraries.
In order for Segment to publish events to a Pub/Sub topic on your behalf, you must grant Segment’s Google Cloud Service Account publish access to your chosen topic. Follow these steps to enable this:
- In your Google Cloud Console, navigate to your Pub/Sub topic list.
- Select one or more topics using the checkboxes to the left of each topic name. Permissions options appear at the right of the page once you make a selection.
- In the Add Members input field, copy/paste Segment’s Service Account email:
- Click the Select a Role drop-down menu and choose Pub/Sub Publisher.
- Click Add.
You should now see the Segment Service Account email as a Pub/Sub Publisher like this:
To use the Google Cloud Pub/Sub destination you must first decide which Segment events to route, and which of your Pub/Sub topics you want to route them to. Define this mapping in your destination settings.
track events can map based on their event name. For example, if you have an event called
User Registered, and you wanted these events to be published to a topic called
projects/my-project/topics/user-registered, you would create a row in your destination settings that looks like this:
Make sure you use the full topic path! Paths are formatted as
You can map any Segment event type (
screen, etc.). This allows you to publish all occurrences of a Segment event type to a specific Pub/Sub topic. To do this, create a row with the event type (track, identify, page, etc.) and its corrensponding topic as in the example below.
Events are case insensitive so
Page is equivalent to
To route all events to a topic, use an
* as the event name.
The structure of a Pub/Sub message uses the PubsubMessage structure.
The Segment destination publishes the entire Segment event payload as a Base64 encoded string, and sets it as the value of the
data parameter in the Pub/Sub message payload. Segment sets the
publishTime to be the
timestamp of the Segment event.
Segment does not currently use the optional
attributes parameter. If you use this functionality, contact us.
For user-property destinations, an identify call is sent to the destination for each user being added and removed. The property name is the snake_cased version of the audience name, with a true/false value to indicate membership. For example, when a user first completes an order in the last 30 days, Personas sends an Identify call with the property
order_completed_last_30days: true. When the user no longer satisfies this condition (for example, it’s been more than 30 days since their last order), Personas sets that value to
When you first create an audience, Personas sends an Identify call for every user in that audience. Later audience syncs only send updates for users whose membership has changed since the last sync.
Real-time to batch destination sync frequency
Note that real-time audience syncs to Google Cloud Pub/Sub may take six or more hours for the initial sync to complete. Upon completion, a sync frequency of two to three hours is expected.
Segment lets you change these destination settings from the Segment app without having to touch any code.
Map your Segment events / event types to your Google Cloud Pub/Sub topics.
This page was last modified: 08 Mar 2022
Questions? Problems? Need more info? Contact Segment Support for assistance!