Documentation / Product / Integrations / Google / Google Cloud Pub/Sub

Google Cloud Pub/Sub: Export Events

Exporting user data to Cloud Pub/Sub allows you to receive real-time audience updates from Lytics on a Pub/Sub Topic in your Google Cloud account.

The integration is similar to Webhooks Audience Triggers. You can either create a topic for Lytics to push to, or the integration can be configured to create one automatically.

Integration Details

  • Implementation Type: Server-side.
  • Implementation Technique: REST API with audience triggers.
  • Frequency: Real-time.
  • Resulting data: Messages on a Pub/Sub Topic. The data attribute of the Pub/Sub messages will be formatted as shown below.

Once configured, the export job will run as follows:

  1. Confirm the configured Topic ID exists. If it does not and you have selected Create Topic, the job will attempt to create one under the Topic ID configured.
  2. Listen for Audience changes.
  3. When a user enters or exits the audience, the event is packaged into a Pub/Sub Message and published to the Topic.


By default, the integration will populate the data attribute of its Pub/Sub messages with all user fields in a JSON payload of the following format:

    "id": "7076027172059065053",
    "data": {
        "_created": "2020-07-15T08:55:43.041-07:00",
        "_cust_sz": 118,
        "_internal_sz": 33,
        "_modified": "2020-07-15T08:55:43.041-07:00",
        "_num_aliases": 1,
        "_num_conflicts": 0,
        "_num_days": 1,
        "_num_events": 1,
        "_num_streams": 1,
        "_split": 12,
        "_streamnames": [
        "_total_sz": 151,
        "channels": [
        "email": "[email protected]",
        "first_name": "Beth",
        "firstvisit_ts": "2020-07-15T08:55:43.041-07:00",
        "hourly": {
            "15": 1
        "hourofweek": {
            "87": 1
        "is_bot": "f",
        "is_mobile": "t",
        "last_active_ts": "2020-07-15T08:55:43.041-07:00",
        "last_channel_activities": {
            "web": "2020-07-15T08:55:43.041-07:00"
        "last_name": "Izzi",
        "lastvisit_ts": "2020-07-15T08:55:43.041-07:00",
        "name": "Beth Izzi",
        "score_frequency": 99,
        "score_intensity": 0,
        "score_momentum": 99,
        "score_propensity": 0,
        "score_quantity": 100,
        "score_recency": 100,
        "segment_events": [
                "id": "42976a269a5e6b9d06c681b1c27292df",
                "event": "enter",
                "slug": "emailzz5",
                "enter": "2020-10-14T13:27:33.916374949-07:00"
        "user_agent": "python-requests",
        "user_attributes": {
            "value": "681"
    "meta": {
        "object": "user",
        "subscription_id": "36e243f8fd8f4530bbd330fa7fb1a685",
        "timestamp": "2020-10-14T13:27:34.038154562-07:00"


Follow these steps to set up and configure an export job for Google Cloud Pub/Sub in Lytics.If you are new to creating jobs in Lytics, see the Jobs Dashboard documentation for more information.

  1. Select Google CLoud from the list of providers.
  2. Select the Cloud Pub/Sub Export job type from the list.
  3. Select the Authorization you would like to use or create a new one.
  4. Enter a Label to identify this job you are creating in Lytics.
  5. (Optional) Enter a Description for further context on your job. pubsub export configuration 1/22/21
  6. From the Audiences input, select which Lytics Audience(s) to emit events from. Each enter/exit event from the selected audiences will be sent to the Pub/Sub topic.
  7. From the Create Topic checkbox, select whether you would like Lytics to automatically create the Topic. If the Cloud Pub/Sub topic does not yet exist and this is selected, Lytics will create one under the configured Topic ID.
  8. From the Topic ID text input, enter the Topic ID of the Cloud Pub/Sub topic.
  9. From the CloudEvents checkbox, select to send Pub/Sub messages as v1.0 JSON CloudEvents.
  10. From the CloudEvents Type text input, enter a custom CloudEvents type. If left empty, the default type is com.lytics.audience.user.event. This is only relevant if you have selected CloudEvents.
  11. From the CloudEvents Source text input, enter a custom CloudEvents source. If left empty, the default source is /work/id. This is only relevant if you have selected CloudEvents.
  12. From the Existing Users checkbox, select whether to add users who already exist in the selected Lytics audiences.
  13. From the Export Fields input, select which user fields to export. The default is to send all fields.
  14. Click Start Export.