๐Ÿ–ฅ๏ธServer-side Conversions

Optibase exposes an API endpoint you can call from the server to trigger a Conversion.

Endpoint

URL: https://app.optibase.io/api/script/conversionEvent

Method: POST

Headers

  • Content-Type: application/json

Request Body

The body must be a JSON object that contains the following fields:

Sample Request Body

{
  "publicApiKey": "clv3047v70dsat664sgrzwotq",
  "userFriendlyConversionId": "serverside_conversion",
  "testedUserId": "clr6hq6y70001qv4jpwag4asd"
}

or

{
  "publicApiKey": "clv3047v70dsat664sgrzwotq",
  "userFriendlyConversionId": "serverside_conversion",
  "testedUserExternalId": "id123"
}

Public API Key

You can find it here: https://app.optibase.io/apiKeys

Make sure to use the Public API Key and NOT the Secret one.

User-Friendly Conversion ID

Create a Programmatic Conversion and copy the ID by clicking on the copy field in the trigger column:

Tested User ID

When a user visits your page, the Custom Optibase Script generates a Tested User ID for the user. You will need to get this ID from the Optibase Script and store it on the server to call the Optibase API Endpoint later and trigger a Conversion for this specific user.

You get this from each user separately with custom JavaScript on the website where you have the Optibase Script setup. The Optibase Script assigns the generated Tested User ID to a global variable you can read with the custom JavaScript.

The global variable is window.optibaseTestedUserId which is a string.

Tested User External ID

Alternatively, you can assign an External ID to the Tested User by calling window.optibaseSetTestedUserExternalId(externalId: string): Promise<void>

The External ID is usually the ID you have assigned to your user in your database.

If you do that, you can call the Optibase API Endpoint with that new External ID, and you don't have to store the Tested User ID mentioned above.

The Tested User External ID will then also be assigned to the global variable window.optibaseTestedUserExternalId.

Last updated