Events represent actions that a user took while on your site. These events are defined and passed to Contentsquare through your client-side code via the Events API. The event could be sent as soon as the page loads, when a modal appears, or when a user sees a specific variation of your page through an A/B test.
Making calls to the Events API
Basic usage:
window._uxa.push(["event", "eventName"]);
Example usage:
window._uxa.push(["event", "subscribed_to_email_list"]);
Parameter definitions
Field | Type | Description |
---|---|---|
event |
string |
Must always be the first parameter - literal string "event". |
eventName |
string |
The custom name assigned to your event (for example: opened_modal). |
Key considerations
- Event naming rules: Max 250 characters. Allowed characters include a-z, A-Z, 0-9, spaces, underscores (_), dashes (-), periods (.), colons (:) and slashes (/).
- Unique event cap: 10,000 unique events per site. Only the most-used events will be retained beyond this limit.
- No event properties: You can’t pass event properties - only the name.
Best practices
- Do not pass Personal Identifying Information (PII) such as email or IP addresses. To connect data with specific users, explore the User Attributes feature.
- Do not use events to transmit 9+ digit numbers (to prevent credit card info).
- Avoid passing detailed error logs or referral codes.
- Avoid passing date strings, timestamps, or data from objects such as Google Tag Manager data layers that may contain excess values.
- If you're also using the Identify API, trigger the Identify call before the Event call.
- Avoid sending product-specific info (for example: SKU codes), usually URLs are more useful and are captured by default.
Testing events
1. Enable debug logging.
Open the page where you want to test the Event and add the ?hjDebug=1
parameter to the end of the URL.
For example:
- https://www.example.com/?hjDebug=1
- https://www.example.com/?utm_1234&hjDebug=1
2. Open your browser's Developer Console.
3. Fire your event manually by running the Events API command.
Add the Event API code in your browser console and press Enter or Return on your keyboard. Look for this confirmation log:
COMMAND: Processing command: event example_action
We also recommend that you go through the steps that your user would, to trigger the event automatically. If the event is fired automatically, then you'll know that your code is implemented successfully. If manual works but automatic doesn't, you'll need to revisit your code implementation.