Number of days visited in last X days

Bronze Contributor
Bronze Contributor

Hi,

 

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.

 

Thanks

2 REPLIES 2

Number of days visited in last X days

Tealium Employee

Hi @do

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.

This variable would contain a String representation of the current date, without any time component.  For example, if you can use an iQ JavaScript extension scoped to the Collect tag, you could do this;

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.

Number of days visited in last X days

Bronze Contributor
Bronze Contributor

Hi @mark_reddin,

Correct, your solution helped me achieve this!

Thanks

Public