# Google Cloud Function Destination

## Destination Info

* Accepts [Page](/docs/segment/connections/spec/page), [Alias](/docs/segment/connections/spec/alias), [Group](/docs/segment/connections/spec/group), [Identify](/docs/segment/connections/spec/identify), [Track](/docs/segment/connections/spec/track) calls.
* Refer to it as **Google Cloud Function** in the [Integrations object.](/docs/segment/guides/filtering-data/#filtering-with-the-integrations-object)
* This destination is **Beta.**

### Components

* Server

Segment makes it easy to send your data to Google Cloud Function (and lots of other destinations). Once you collect your data using Segment's [open source libraries](/docs/segment/connections/sources/catalog/), Segment translates and routes your data to Google Cloud Function in a format it can use.

[Google Cloud Function](https://cloud.google.com/functions) is a lightweight compute solution for developers to create single-purpose, stand-alone functions that respond to Cloud events without the need to manage a server or runtime environment.

> \[!IMPORTANT]
>
> This means the feature is actively being developed, and some functionality may change before it becomes generally available.

## Getting Started

### Build a Google Cloud Function to Process Segment Events

Before you can process events from Segment, you must provide a Google Cloud Function that can handle your incoming events.

1. Go to [https://cloud.google.com/functions](https://cloud.google.com/functions).
2. Click **VIEW CONSOLE**.
3. Select a project.
4. Click **CREATE FUNCTION**.
5. Enter a name for your function, and choose how much memory the function can use.
6. In the **Trigger** field, select `HTTP`. Save the `URL` GCP gives you. You'll use this to configure the Segment destination later.
7. Choose how you'll provide the function's code (in the **Source code** field) and what language the code is written in (in the **Runtime** field).
8. Enter the name of the function as you defined it in your code, in the **Function to execute** field.
9. Click **Create** to save your settings and create the Google Cloud Function.

#### Test the function

Segment recommends that you use the Debugger of the source you intend to connect to the Google Cloud Function destination to inspect the request body of the incoming event. This allows you to build handlers in your function based on accurate incoming data. For more information, see [Testing Connections](/docs/segment/connections/test-connections/).

### Configure the Google Cloud Function Destination

Once you create the Google Cloud Function, you can set up a Segment destination that calls the function.

1. Log in to the Segment app and select the workspace you want to work in.
2. Click **Catalog** and search for **Google Cloud Function**.
3. Click **Configure Google Cloud Function**.
4. Enter the destination settings for this GCF destination.

| Setting                | Description                                                                                                                                                                                                                                                               |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **HTTP Trigger**       | The URL given under the `Trigger` section when you created the Google Cloud Function.                                                                                                                                                                                     |
| **API Key** (optional) | A string to identify that a request is coming from Segment, if required by the function. <br /><br />The API key is injected in the `Authorization` header as a [basic authorization header](https://en.wikipedia.org/wiki/Basic_access_authentication) without password. |

## Engage

You can send computed traits and audiences generated using [Engage](/docs/segment/engage) to this destination as a **user property**. To learn more about Engage, schedule a [demo](https://segment.com/contact/demo).

For user-property destinations, an [identify](/docs/segment/connections/spec/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, Engage 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), Engage sets that value to `false`.

When you first create an audience, Engage 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.

> \[!NOTE]
>
> Real-time audience syncs to Google Cloud Function  may take six or more hours for the initial sync to complete. Upon completion, a sync frequency of two to three hours is expected.

## Settings

Segment lets you change these destination settings from the Segment app without having to touch any code.

| Field        | Description                                                | Required | Type   |
| ------------ | ---------------------------------------------------------- | -------- | ------ |
| API Key      | The api key used to identify request performed by Segment. | No       | string |
| HTTP Trigger | The URL to call the Google Cloud Function.                 | Yes      | string |
