To gain a deeper understanding of customer behavior, it is beneficial to track the number of unique days your customers engage with your business.
It includes activities such as visiting the website, making purchases, adding items to the cart, and other relevant events. Analyzing these unique engagement days can provide valuable insights into customer habits, preferences, and loyalty.
To build this use case, create an expression for the event you want to use in your analytics. This example uses the session_start event to show how many unique days customers visited the website.
The expression should look like this:
The expression floor((timestamp + 3600) / 86400) returns the integer part of the number of days since the Unix epoch, with a 1-hour adjustment added to the timestamp. This integer value represents the "day" part of the adjusted timestamp.
Operations:
- Addition (timestamp + 3600):
- It adds 3600 seconds (one hour) to the original timestamp to account for time zone differences, or rounds it up to the next hour.
- Division by 86400 ((timestamp + 3600) / 86400):
- It converts the timestamp (plus one hour) into the number of days since the Unix epoch. Dividing by 86400 seconds (one day) converts the total number of seconds into a fraction representing the number of days.
- Floor Function (floor(...)):
- The floor function rounds down to the nearest whole number, returning only the integer part of the days since the Unix epoch.
It creates a unique number for each day of event occurrence (if there are multiple events on a given day, they will all share the exact number).
Report to calculate the unique event occurrences
Next, create a report without metrics, since all necessary calculations will be performed at the drill-down level.
The report uses ID, in this case registered as the identifier to which the number of event occurrences will be attributed, and the following aggregate: count distinct - {{ your event }} - {{ your event expression }}, which will count the number of unique occurrences of your event per customer.
Once this setup is complete, you'll be able to see unique event occurrences for each customer and get a better understanding of their behavior.