User event
Detailed user
event guide
The user
event is a fundamental aspect of user analytics, enabling consistent tracking and reference across their lifetime.
Whether you’re dealing with registered users or anonymous visitors, the user
event helps you associate meaningful data with each individual.
This documentation provides detailed guidance on utilizing the user
event to enrich
your user data for more personalized and insightful analytics.
First of all, you don’t need to fire an user
event for every user action. Instead, you should fire it when
you first learn about a user, and then update the user’s information as it changes (for example, when they update their profile, or when they first register).
How It Works
When you fire a user
event using the Edgee SDK or Data Layer, we securely process the user data at the edge and make sure all subsequent events are bound to that user.
Here’s how it works across different platforms:
- Browser: Edgee stores the user data in an encrypted first-party cookie. This ensures privacy and compliance while persisting the data across sessions.
- Edge Processing: Unlike traditional client-side solutions, Edgee processes the user data at the network edge, eliminating the need for heavy local storage and enhancing data accuracy.
This architecture ensures that all subsequent page
or track
events are seamlessly enriched with the user’s data. As a result, actions can be properly attributed, providing a complete and accurate view of user behavior.
In addition to that, some components support the user event natively, such as Amplitude and Segment.
For these components - in addition to enriching the page
and track
events for them as well - every time you make a user
call, Edgee will send the appropriate event to the component (e.g. identify
for Segment).
When to use the user
event
The user
event is particularly useful in scenarios where you collect information about a user without having a definitive userId
, such as:
- Capturing an email address during a newsletter sign-up.
- Associating actions with an anonymous user before they create an account.
- Updating user traits after a profile update or preference change.
Event fields
The user
event collects the following fields about the user:
Field | Type | Description |
---|---|---|
user_id | String | A unique identifier for the user, typically from your own user database. |
anonymous_id | String | An alternative identifier used when a user_id is not available, ensuring that user actions can still be collected anonymously. |
properties | Object | Free-form dictionary of properties of the user |
Privacy Notice: This method and all the fields it collects are subject to data privacy regulations. When collecting user data, always prioritize user privacy and data protection. Ensure that you are compliant with relevant data privacy regulations and obtain user consent before collecting any personal information.
How to collect the user
event?
There are two ways to collect the user
event:
1 - Automatically with the Edgee Data Layer
Edgee collects the user
event automatically each time it receives a Data Layer with a user
event.
Here’s a breakdown of how to structure the Data Layer:
2 - Manually
The user
event can be collected manually by calling the edgee.user()
method via the Edgee SDK.
Here’s a breakdown of how to structure an user
call:
As usual, you can optionally specify the components where the event should be sent. If the components parameter is not
specified, Edgee will look at data_collection.components
in the Data Layer. If not defined, the event will be sent to all your components.
The edgee.user()
method expect two optionals parameters:
field | type | description | |
---|---|---|---|
user_obj | optional | object|String | A free-form dictionary object containing details of the user event. This object can include all the following optional fields: user_id , anonymoudId , and properties . You can also provide a string that will be used as the user_id field. |
components | optional | object | Specifies which analytics components should receive the event data. This allows for targeted data sending based on your configured components within the Edgee platform. |
Best Practices for user
Events
- Consistent Identification: Use consistent identifiers across your application to ensure accurate user tracking. Decide on a standard for when to use
user_id
versusanonymous_id
and stick to it. - Relevant Properties: Only include properties that offer actionable insights. Avoid collecting sensitive or unnecessary information to maintain data integrity.
- Selective Destination Sending: Utilize the components parameter to fine-tune where your data is sent, optimizing for relevance and efficiency.
- Privacy Compliance: Ensure that you are compliant with relevant data privacy regulations when collecting user data. Always prioritize user consent and data protection.