Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New report "Visitors Recency", days since last visit #583

Closed
mattab opened this issue Mar 3, 2009 · 21 comments
Closed

New report "Visitors Recency", days since last visit #583

mattab opened this issue Mar 3, 2009 · 21 comments
Assignees
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@mattab
Copy link
Member

mattab commented Mar 3, 2009

We could provide a new report: days since last visit

Example

You have 1000 unique visitors;
- 500 are new visitors
- 300 visited your site 1 day ago
- 100 visited your site between 2 and 5 days ago
- 10 visited your site between 5 and 15 ago
- etc.

@mattab
Copy link
Member Author

mattab commented Jan 13, 2011

See note in #1434

@mattab
Copy link
Member Author

mattab commented Jan 17, 2011

Example: For the month of August,

Last visit the same day: X

Last visit 1 day ago: Y

Last visit 2 days ago: Z

[..]

Last visit 7 days ago

Last visit 8-14 days ago

Last visit more than 15 days ago

Keep a counter 'last_visits_days' in log_visit

See also #536

Recency
see http://www.webanalyticsassociation.org/resource/resmgr/PDF_standards/WebAnalyticsDefinitions.pdf


Recency
Type: Count
Calculation:
Time since a unique visitor performed a specific action of interest to the analyst.
Notes:
The action in the above definition can be anything of interest to the analyst - visit, purchase,
download, use of a certain service, etc. Most often recency is associated with either a visit or a
purchase. Further, the unit of measure for recency can be at any level of time -- hours, days,
months, etc.
As an example, let us say the action of interest is the purchase of a certain product. Visitor A
last purchased that product 30 days ago and Visitor B last purchased that product 90 days ago.
The recency for Visitor A will be 30 (if measured in days) or 1 (if measured in months) and for
Visitor B will be 90 (if measured in days) or 3 (if measured in months).

@mattab
Copy link
Member Author

mattab commented Jan 17, 2011

See also #2031, #566, #2448 for ecommerce report

@mattab
Copy link
Member Author

mattab commented Feb 8, 2011

Schema update at least, to be done in 1.2 as part of 1st party cookie implementation.

@anonymous-matomo-user
Copy link

Not sure if this can be accommodated into this feature, but I would especially love to see this data in the Visitor's Log. (i.e., for each visit in the log, when was the last time this visitor came).

@diosmosis
Copy link
Member

I'd like to start working on this ticket, but I've got a couple questions:

  1. This report will be part of the Engagement section, correct?

  2. How exactly will the report look?

  3. Assuming bohare's suggestion is doable, would it be ok if the extra information was added to the Date column of the Visitor's Log?

Thanks in advance!

@mattab
Copy link
Member Author

mattab commented Oct 28, 2011

Great news! :)

  1. Makes sense, The page will get bloated but I guess it's ok (we can organize better later)

Days Since Last Visit
0
1   
2   
3   
4   
5   
6   
7   
8-14    
15-30   
31-60   
61-120  
121-364 
365+

Should use the visitor_days_since_last field

2)Yes doable, but not displayed by default (too much noise). I propose to display it on hover over the date (in title tooltip).

@diosmosis
Copy link
Member

Came across a problem while implementing this. The 'days since last visit' report can't be applied to new visits. I can make the report only deal with returning visits, or I can display the count of new visits in the report. In the latter case, I could prepend a row to the report so it would look like this:

Days Since Last Visit
New Visits
0
1
2
3
...

It would show more information, but might be a bit confusing.

Which approach do you think is better?

@mattab
Copy link
Member Author

mattab commented Oct 30, 2011

I think it makes sense to report "New visits" in the report.

@diosmosis
Copy link
Member

Attachment: Patch for issue #583, made for revision 5398.
issue583.tar.gz

@diosmosis
Copy link
Member

Just uploaded a patch for this issue. The patch is made for revision 5398. Could you review it and let me know your thoughts? Thanks in advance.

One note, sorting is disabled for this new report, though I could change this.

@mattab
Copy link
Member Author

mattab commented Nov 3, 2011

capedfuzz, great work. I have granted you SVN access (congratulations). With great power comes great responsability :)

Enjoy the ride!

@diosmosis
Copy link
Member

(In [5411]) Fixes #583:

Added "Days since last visit" report under Visitors > Engagement.
Added tooltip to visitor log that displays the days since a visitor's last visit for each visit.

Notes:

The new report has been added to the Metadata API.
Augmented range label beautification so non-range labels could be displayed if desired.
Modified archiving code to allow further refinement when summarizing data over ranges.

@mattab
Copy link
Member Author

mattab commented Nov 8, 2011

Great commit!!
Unfortunately it does not work for me in my basic test. See attached screenshot. Does it work in your piwik?

Otherwise all looks good

@mattab
Copy link
Member Author

mattab commented Nov 8, 2011

Attachment: all zeros
Web Analytics Reports - Test7 MyNamescript type=.png

@diosmosis
Copy link
Member

If I use the visit generator, I get a result that isn't all 0s. If the specific visits you're viewing are exactly one year since the first visit, then I think I found the problem. Either way, I'm going to do some more testing (and possibly add another integration test).

@diosmosis
Copy link
Member

I did more testing, and it seems to work fine for me.

I added the following code to the integration tests (not committed, just locally):

    public function test_OneVisitor_AllYear()
    {
        $apiToCall = array('VisitorInterest.getNumberOfVisitsByDaysSinceLast');
        $dateTime = '2010-01-01 11:22:33';
        $idSite = $this->createWebsite($dateTime);

        for ($i = 0; $i != 370; ++$i)
        {
            $newDateTime = Piwik_Date::factory($dateTime)->addDay($i)->getDatetime();

            $visitor = $this->getTracker($idSite, $newDateTime, $defaultInit = true);
            $visitor->setUrlReferrer( 'http://referer.com/page.htm?param=valuewith some spaces');
            $visitor->setUrl('http://example.org/index.htm');
            $visitor->setForceVisitDateTime($newDateTime);
            $visitor->DEBUG_APPEND_URL = '&_viewts='.Piwik_Date::factory($dateTime)->getTimestamp();
            $this->checkResponse($visitor->doTrackPageView('page view'));
        }

        $this->setApiToCall($apiToCall);

        $this->callGetApiCompareOutput(__FUNCTION__, 'xml', $idSite, $dateTime, $periods = array('year'), 
            $setDateLastN = false, $language = false, $segment = false, 
            $visitorId = false, $abandonedCarts = false, $idGoal = false);

        $this->callGetApiCompareOutput(__FUNCTION__ . '2', 'xml', $idSite, '2011-01-03 11:22:33', $periods = array('year'),
            $setDateLastN = false, $language = false, 
            $segment = false, $visitorId = false, $abandonedCarts = false, $idGoal = false);
    }

and everything worked as expected. Can you give me more information?

@diosmosis
Copy link
Member

(In [5428]) Refs #583, #584, #2031

Fixed bug with ranges that, for some new range reports, caused certain visits to not be counted. This fix will cause a cosmetic change in the two older reports in the VisitorInterest plugin (the 'visits per duration' & 'visits per actions' reports).

@mattab
Copy link
Member Author

mattab commented Dec 16, 2012

Milestone 1.8.x Piwik 1.8.x deleted

@mattab mattab added this to the 1.12.x - Piwik 1.12.x milestone Jul 8, 2014
@mattab mattab self-assigned this Jul 8, 2014
@Akuukis
Copy link

Akuukis commented Jun 16, 2015

Hello, I would like to clarify on this feature for few cases

  1. If at this moment it is 01:00 and visitor last time visited a page at 23:00 last day (2 hours ago), will it show up as "0 days since" or "1 days since"?
  2. If visitor started a visit before midnight and ended after midnight, and then visited after 12 hours in day, will it show up as "0 days" or "1 days"?
  3. Is it possible to edit settings to alternate between both outcomes in above cases?

P.S. In my page I believe people look once a day, but 80+% of returning traffic is "0 days".

@mattab
Copy link
Member Author

mattab commented Jun 18, 2015

@Akuukis the code is here: https://github.com/piwik/piwik/blob/2.13.1/core/Tracker/Request.php#L184-203

Piwik processes the value as accurately as possible. If a visitor first visited more than 86400 seconds ago, then it will have a "Days since first visit" of 1 or more

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

4 participants