Skip to main content

Example

What you'll build​

Build an integration workflow that connects to RudderStack and records a customer action. The workflow sends a track event to the RudderStack Event Stream API and logs the response.

Operations used:

  • track : Records an Order Completed event for a user in RudderStack, which routes it to the destinations connected to the source

Architecture​

Prerequisites​

  • A RudderStack HTTP source with its write key, and the data plane URL of your workspace (see the Setup Guide)

Setting up the RudderStack integration​

New to WSO2 Integrator? Follow the Create a New Integration guide to set up your integration first, then return here to add the connector.

Adding the RudderStack connector​

Step 1: Open the connector palette and search for the connector​

Select Add Artifact, then select Connection to open the connector palette. Search for rudderstack and select the Rudderstack connector card.

Add Connection palette open with the search field before any selectionAdd Connection palette open with the search field before any selection

Configuring the RudderStack connection​

Step 2: Fill in the connection parameters​

Enter the connection parameters, binding each field to a configurable variable:

  • Config : ConnectionConfig record with the source write key; switch to Expression and enter {auth: {writeKey: rudderstackWriteKey}}
  • Service Url (under Advanced Configurations) : The data plane URL of your workspace; bind to the rudderstackDataPlaneUrl configurable variable
  • Connection Name : Keep the default rudderstackClient
RudderStack connection form filled with configurable variables before savingRudderStack connection form filled with configurable variables before saving

Step 3: Save the connection​

Select Save Connection. The connection appears under Connections in the project tree and on the design canvas.

Design canvas showing the saved rudderstackClient connectionDesign canvas showing the saved rudderstackClient connection

Step 4: Set actual values for your configurables​

  1. In the left panel, select Configurations.
  2. Set a value for each configurable listed below:
  • rudderstackWriteKey (string) : The write key of your RudderStack HTTP source
  • rudderstackDataPlaneUrl (string) : The data plane URL of your workspace, for example, https://<your-workspace>.dataplane.rudderstack.com

Configuring the RudderStack track operation​

Step 5: Add an automation entry point​

Select Add Artifact, then select Automation and select Create to add the automation entry point to the canvas.

Step 6: Select and configure the track operation​

  1. On the automation canvas, select the + button to add a step.
  2. Expand the rudderstackClient connection under Connections.
rudderstackClient connection expanded in the node panel showing the available operationsrudderstackClient connection expanded in the node panel showing the available operations
  1. Select Track (track) and configure it:
  • Payload : Switch to Expression and enter {userId: "u-1001", event: "Order Completed", properties: {"orderId": "o-5001", "revenue": 89.99, "currency": "USD"}}
  • Result : Set the result variable name to result
track operation form with the event payloadtrack operation form with the event payload
  1. Select Save to add the operation to the flow, then add a Log Info step after it, switch Msg to Expression and enter result. RudderStack returns ok when it accepts the event.
Completed automation flow with the track operation and a log stepCompleted automation flow with the track operation and a log step

Try it yourself​

Try this sample in WSO2 Integration Platform.

Deploy to Devant

View source on GitHub

More code examples​

The RudderStack Ballerina connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering use cases like customer journey tracking, signup attribution and profile activation.

  1. Customer journey tracking - Identify a customer, record the product page they view, then send their add-to-cart and order events together in one batch.

  2. B2B signup attribution - Record an anonymous visitor's landing page view with its campaign, link the visitor to the new user ID at signup, record the user's traits, and associate the user with their company.

  3. Profile refresh and activation - Start a Profiles run, poll it until it finishes, then fetch the refreshed profiles of a few customers through the Activation API.