Automate events tracking
Track user behaviour with Weespin API
Track user behavior and analytics in your application with Weespin's event tracking REST API to measure conversions, analyze engagement, and optimize your campaigns.
With the Weespin Events API, you can:
- Track custom events (purchases, sign-ups, add to cart).
- Associate events with users and generated links.
- Collect valuable data to improve your product.
Get your API keys
- Log into your Weespin dashboard.
- Go to your application.
- Go to the Configuration section.
- In Integration:
- Generate the API key that will be used to identify your application.
Store your keys in a secure file or environment variable.
Understand the API documentation
Before coding, it's essential to know:
- API base URL:API_BASE_URL
- Main endpoints:
POST /events/initialize→ initialize device sessionPOST /events→ track user events - Integration workflow:
- Initialize device (once per session)
- Log events (with
userIdfor all subsequent calls)
Initialize device
Before sending any events, you must initialize the device. This step is performed once at the start of the session and registers the device with the Weespin platform.
Endpoint: POST /initialize-device
Example request:
Response:
Crucial: You must store this device_info.device_id (in local storage, a cookie, or your database) and include it in all subsequent tracking calls to identify the user.
Log events
Once the device is initialized, you can track user actions by sending events.
Endpoint: POST /events
Required parameters:
purchase, add_to_cart) Other parameters:
Important: Always include the device_id parameter to associate events with specific users across sessions.
Example request:
Response:
Payload rules:
event_namemust be a non-empty string.payloadmust be a JSON-compatible object.- Supported types:
string,int,double,boolean
Common event names:
add_to_cart- User adds a product to cartpurchase- User completes a transactionsignup- New user registrationlogin- User authenticationshare_link- User shares contentopen_app- App launch
Security notice: Never send sensitive personal data (passwords, credit card numbers, social security numbers) in event payloads.
Practical implementation examples
Replace YOUR_API_KEY with your actual API key from the dashboard.
Conclusion
You now have the tools to integrate event tracking into your application! Use the Weespin Events API to track user behavior, measure conversions, and optimize your product based on real data.