Google Cloud Function Destination

Segment makes it easy to send your data to Google Cloud Function (and lots of other destinations). Once you track your data using our open-source libraries we’ll translate and route your data to Google Cloud Function in the format they understand. Learn more about how to use Google Cloud Function with Segment.

Google Cloud Function 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.

NOTE: Google Cloud Function is currently in beta, and this doc was last updated on May 6, 2019. This means that there may still be some bugs for us to iron out and we’re excited to hear your thoughts. If you are interested in joining or have any feedback to help us improve the Google Cloud Function Destination and its documentation, let us know!

Getting Started

Before you start, make sure Google Cloud Function supports the source type and connection mode you’ve chosen to implement. You can learn more about connection modes here.

Web Mobile Server
📱 Device-mode
☁️ Cloud-mode

Build a Google Cloud Function to Process Segment Events

In order to process events from Segment, you will need to provide a Google Cloud Function that can handle your event flow:

  • Go to
  • Click on VIEW CONSOLE.

  • Select a project.

  • In the Name field, give a name to your function.
  • In the Memory allocated field, define how much memory your function can use.
  • In the Trigger field, select HTTP. Then keep the given URL in order to configure your segment destination.
  • In the Source code field, select how you will provide your function code.
  • In the Runtime field, select what language is used in your code.
  • In the Function to execute field, type the name of your function as it is defined in your code.
  • Click on Create to create the Google Cloud Function.

Configure Google Cloud Function Destination

Once the Google Cloud Function is created, a destination that will call the function must be configured:

  • In our Destinations section, click on Add Destination. You will be redirected to our Catalog.
  • Search and client on Google Cloud Function destination.
  • Click on Configure Google Cloud Function.
  • Fill the settings.


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.

The API key is injected in the Authorization header as a basic authorization header without password. See

Deciding whether to check the API key depends on the function implementer.


You can send computed traits and audiences generated using Segment Personas to this destination as a user property. To learn more about Personas, contact us for a demo.

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 indicade 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 false.

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.


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


The api key used to identify request performed by Segment.

HTTP Trigger

The URL to call the Google Cloud Function.

This page was last modified: 17 Jul 2020

Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
Create free account