# Google PubSub

> Publish your Ours Privacy event data to a Google Cloud Pub/Sub topic in real time to trigger your own processing in Google Cloud.

Source: https://docs.oursprivacy.com/docs/google-pubsub

Use this page to connect Ours Privacy to **Google Cloud Pub/Sub**. Each event is published to your topic as it happens, so subscribers in Google Cloud can process it, trigger workflows, or load it into analytics.

---

## Before you start

- A Pub/Sub topic, with its topic ID and the ID of the Google Cloud project that contains it.
- Publish permission on the topic for the Ours Privacy service account. Contact [support@oursprivacy.com](mailto:support@oursprivacy.com) for the service account to grant the **Pub/Sub Publisher** role to.

## Setup

1. Open the [Destinations](https://app.oursprivacy.com/destinations) page and add a **Google PubSub** destination.
2. Enter the following:
   - **GCP Project ID**: the Google Cloud project that contains the topic.
   - **Topic ID**: the topic to publish to.
3. Save the destination and publish a new version to start sending events.

Each message uses the visitor ID as its ordering key, or the event's `distinct_id` when there's no visitor ID.

## Event format

Each message is one event with its visitor and user records:

```json
{
  "event": {
    "event": "Order Completed",
    "distinct_id": "evt_789",
    "time": "2026-01-15T18:04:12.000Z",
    "event_properties": {
      "order_id": "12345",
      "total": 99.99
    }
  },
  "visitor": {
    "visitor_id": "visitor_123",
    "first_seen_at": "2026-01-01T00:00:00Z",
    "email": "example@example.com"
  },
  "user": {
    "external_id": "user_456",
    "email": "example@example.com"
  }
}
```

- `event` is the event as Ours Privacy received it, with its name, properties, and `distinct_id`.
- `visitor` is the profile of the visitor who triggered the event.
- `user` combines every visitor profile that shares the visitor's external ID.

The records arrive whole, contact details included, so field mappings and hashing don't apply to this destination. To keep an event from reaching it, [stop dispatch](https://docs.oursprivacy.com/docs/understanding-the-event-flow#step-3-optional-custom-mapper) with a custom mapping or a [Global Data Governance](https://docs.oursprivacy.com/docs/global-data-governance) rule.

## Filter messages for your organization

Each message includes two Pub/Sub attributes alongside its event data:

- `ours_org_id`: your Ours Privacy organization ID.
- `ours_destination_id`: the ID of the destination that published the message.

To receive messages for one organization and destination, create a subscription with this filter, replacing the placeholders with your IDs:

```text
attributes.ours_org_id = "<your-org-id>" AND attributes.ours_destination_id = "<your-destination-id>"
```

For all destinations in your organization, use only the `ours_org_id` condition. Contact your account representative if you need help finding these IDs.

You can also check both attributes in your consumer before processing a message. Skip processing when values are missing or unexpected. Ours Privacy sets these attributes from the configuring destination; they are routing metadata, not proof of the publisher's identity. Keep your topic's publish permissions restricted to the service account provided during setup.

Pub/Sub subscription filters are fixed when you create the subscription. To change an existing filter, create a replacement subscription. See Google's [subscription filtering guide](https://docs.cloud.google.com/pubsub/docs/subscription-message-filter) for setup instructions.

## Delivery guarantees

Events are delivered at least once, so a retry can deliver the same event more than once. Deduplicate on `event.distinct_id`, which stays the same on every delivery of an event. Every event from a visitor shares `visitor.visitor_id`, so it can't tell two events apart.

---

## Next steps

- [Destination overview](https://docs.oursprivacy.com/docs/destination-overview): how destinations fit into the event pipeline.
- [AWS Lambda](https://docs.oursprivacy.com/docs/aws-lambda), [AWS Kinesis](https://docs.oursprivacy.com/docs/aws-kinesis), and [AWS SNS](https://docs.oursprivacy.com/docs/aws-sns): send the same payload into AWS.

## Need help?

Reach out to [support@oursprivacy.com](mailto:support@oursprivacy.com).
