Server-Side API Endpoint
This container type enables you to easily send and receive any data model to spesicific destination using server-side enpoint and custom subdomain.
We are currently performing maintenance on this guide.
Server-side Google Analytics 4 Measurement Protocol Endpoint Guide
Endpoint: api.usehardal/mp/gtag/:containerID
Overview
This endpoint allows you to integrate Google Analytics tracking into Hardal tool using the Measurement Protocol. It processes tracking data based on the provided containerID
.
Request Type
- Method:
GET
Parameters
Parameter | Description | Required/Opt. |
---|---|---|
containerID | ID of the container in the database. | Required |
client_id | Client ID for tracking. | Required |
event_name | Event name to be tracked. | Required |
timestamp_micros | Number, timestamp in microseconds. | Optional |
user_id | String, user identifier. | Optional |
user_properties | Object, additional user properties. | Optional |
consent | Object, user consent details. | Optional |
non_personalized_ads | Boolean, indicating non-personalized ads. | Optional |
Examples
Example Request
curl -X GET "https://api.usehardal.com/mp/gtag/yourContainerID?client_id=123&event_name=purchase"
Example Response
{
"data": { "example_key": "example_value" },
"target": "yourContainerID",
"params": { "client_id": "123", "event_name": "purchase" }
}
Error Handling
- If the specified
containerID
is not found, an error will be thrown. - If mandatory parameters (
client_id
orevent_name
) are missing, an error will be thrown. - Other errors may occur, providing detailed error messages.
Integration Steps
-
Retrieve Container Information: Ensure the specified
containerID
exists. -
Extract Container Settings: Retrieve settings including
measurement_id
,api_secret
, etc. -
Handle Queries: Extract and validate mandatory and optional queries.
-
Construct Payload: Filter and construct a payload based on the extracted data.
-
Send Data to Google Analytics: Use the
postAnalytics
function to send the payload. -
Return Response: Return a JSON response with data, target container ID, and processed parameters.
Additional Notes
- Adjust the base URL according to Hardal.
- Customize error messages and handling based on your requirements.
Feel free to adapt the provided cURL example and adjust the code to suit Hardal API's specific needs.