I would like to count the number of unique days a visitor has visited my website in the last 7 days.
E.g. I want to create an audience for visitors who have visited more than 5 out of the last 7 days.
I can not produce this with a timeline attribute, as I don't know how to count only a single or the first event of a day.
Hope you can help with this.
Solved! Go to Solution.
You wish to know the number of calendar days over the last 7 days that the user has visited.
What you ask is not possible currently in "Pure" UDH, so we would need an iQ extension or if not iQ another UDH event variable set externally, to help.
var d = new Date(); b.as_calendar_date = d.getUTCFullYear() + '/' + (d.getUTCMonth() + 1) + '/' + d.getUTCDate();
Then, in UDH, declare as_calendar_date as an Event Level String so you have access to it.
Now, what you can do is to declare also a Visitor Level String variable called say vrStrCalendarDate, and set it from the as_calendar_date on any event.
Then, in your timeline, record an entry on any event, if vrStrCalendarDate satisfies the rule "has changed".
The above is not perfect - we are now relying on the client device clock, so for example if a stitched visitor was using different devices that had their clocks set differently, then the results might be incorrect. But this is an edge case since modern devices usually use a network time protocol to keep their clocks set. You will also notice that I pass UTC date to remove time zones from being a concern.