Prerequisites
- An active Writesonic account
- Development access to your website or application
- Ability to make HTTP POST requests from your server
- Access to request headers and metadata
Phase 1: Start in Writesonic
- Head over to the AI Bot Analytics page on Writesonic and choose ‘Custom’ as a provider
- Click on ‘Continue’ to initialize the integration.
- Writesonic will generate a unique API key for your website.
Phase 2: Get Integration Details
Step 1: Copy the Endpoint URL
Copy the following endpoint URL that you’ll use for sending analytics data:https://ingestion.writesonic.com/api/v1/analytics/ingest
Step 2: Note the Authentication Headers
You’ll need to include the following header in all your requests:- Header Key:
x-api-key - Header Value: Copy the API key provided by Writesonic (unique to your project)
Phase 3: Implement the Integration
Request Format
Make a POST request to the endpoint URL with the following JSON body fields:Curl example
Phase 4: Testing and Verification
Test Your Integration
- Implement the code in your application
- Make a few test requests to your website
- Check that the requests are being sent to the Writesonic endpoint
- Monitor your application logs for any errors
Verify Installation in Writesonic
- Go to AI Bot Analytics Page in Writesonic.
- Click on “Verify Integration” to confirm that your Custom integration is working properly
- Once verified, you’ll be redirected to your analytics dashboard. The process typically finishes in 1–2 minutes but may take up to 5 minutes.
Best Practices
Performance Considerations
- Asynchronous Processing: Send analytics data asynchronously to avoid impacting response times
- Error Handling: Implement proper error handling to prevent analytics failures from affecting your main application
- Rate Limiting: Implement client-side rate limiting to avoid overwhelming the endpoint
Data Quality
- IP Address: Use the most accurate IP address available (consider proxies and load balancers)
- User Agent: Always include the complete User-Agent string
- URL Normalization: Ensure URLs are properly formatted and complete
Security
- API Key Protection: Keep your API key secure and never expose it in client-side code
- HTTPS Only: Always use HTTPS for requests to the Writesonic endpoint
- Data Sanitization: Sanitize user data before sending to prevent injection attacks
Troubleshooting
Common Issues
- 401 Unauthorized: Check that your API key is correct and properly included in headers
- 422 Unprocessable Entity: Verify that your JSON payload matches the required format
- Network Errors: Ensure your server can make outbound HTTPS requests
- Missing Data: Check that you’re capturing all available request headers and metadata
Debugging Tips
- Log Requests: Log the data you’re sending for debugging purposes
- Test with curl: Use curl to test the endpoint manually
- Check Response: Always check the HTTP response code and body for error details
Integrating With Fastly Log Streaming Integrating with Cloudfront