Google Cloud Function Destination
Segment makes it easy to send your data to Google Cloud Function (and lots of other destinations). Once you’ve tracked your data through 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, please let us know!
Getting Started
The first step is to make sure Google Cloud Function supports the source type and connection mode you’ve chosen to implement. You can learn more about what dictates the connection modes we support 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 https://cloud.google.com/functions.
- Click on
VIEW CONSOLE
.
- Select a project.
-
Click on
CREATE FUNCTION
. - 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, selectHTTP
. Then keep the givenURL
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 onAdd Destination
. You will be redirected to ourCatalog
. - Search and client on
Google Cloud Function
destination. - Click on
Configure Google Cloud Function
. - Fill the settings.
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 https://en.wikipedia.org/wiki/Basic_access_authentication.Deciding whether to check the API key depends on the function implementer. |
Personas
You can send computed traits and audiences generated through Segment Personas to this destination as a user property. To learn more about Personas, reach out for a demo.
For user-property destinations, an identify call will be sent to the destination for each user being added and removed. The property name will be the snake_cased version of the audience name you provide with a true/false value. For example, when a user first completes an order in the last 30 days, we will send an identify call with the property order_completed_last_30days: true
, and when this user no longer satisfies we will set that value to false
.
When the audience is first created an identify call is sent for every user in the audience. Subsequent syncs will only send updates for those users which were added or removed since the last sync.
Settings
Segment lets you change these destination settings from your Segment dashboard without having to touch any code.
API Key
The api key used to identify request performed by Segment.
HTTP Trigger
The URL to call the Google Cloud Function.
Need support?
Questions? Problems? Need more info? Contact us, and we can help!