Module hubspot.analytics
ballerinax/hubspot.analytics Ballerina library
2.3.1
Overview
This is a generated connector from HubSpot OpenAPI specification.
These APIs allow triggering instances of custom behavioral events.
Prerequisites
- Create a HubSpot developer account
- Obtain tokens
- Use this guide to obtain the API keys related to your account.
Quickstart
To use the HubSpot Analytics connector in your Ballerina application, update the .bal file as follows:
Step 1 - Import connector
First, import the ballerinax/hubspot.analytics module into the Ballerina project.
import ballerinax/hubspot.analytics;
Step 2 - Create a new connector instance
You can now make the connection configuration using the access token.
analytics:ApiKeysConfig config = { hapikey : "<your apiKey>" }; analytics:Client baseClient = check new Client(clientConfig);
Step 3 - Invoke connector operation
- Send a Custom Behavioral event
analytics:BehaviouralEvent event = { eventName: "pe20436354_e_visited_page", properties: { }, email: "string" }; http:Response|error bEvent = baseClient->sendEvent(event); if (bEvent is http:Response && bEvent.statusCode == 204) { log:printInfo("Created behavoural event"); } else if(bEvent is http:Response) { json payload = check bEvent.getTextPayload(); log:printInfo(payload.toString()); } else { log:printInfo(msg = bEvent.message()); }
- Use
bal run
command to compile and run the Ballerina program