Analytics chart showing incorrect data/dates for Users
See original GitHub issueBug Description
On the Analytics chart, the user count displayed when viewing a single date is actually showing data for the following day.
Additionally, the previous month is showing the same date as the selected range but the data is correct.
The label displayed that represents the previous range doesn’t accurately reflect what is actually being seen. Instead of displaying Previous Month, perhaps the label should show the selected range such as Previous 90 Days. Alternatively, we could mirror what is being done in the Analytics UI and use the actual date ranges.
Discovered while investigating #1280.
Steps to reproduce
Off by one data:
- Go to the Analytics screen in Site Kit
- Hover over any date on the blue line to view User count for that day.
- Compare the same date in Analytics account.
Incorrect previous date:
- Go to the Analytics screen in Site Kit
- Hover over any date on the blue line to view User count for that day.
- Hover the same date on the dashed line
- The dates for both ranges are the same but the User count is correctly displayed.
Screenshots
Off by one data
Incorrect previous date:
The previous date should read Apr 2, 2020 here.
Additional Context
- PHP Version: 7.2
- OS: Mac OS
- Browser: Crome
- Plugin Version: develop branch.
- Device: MacBook Pro
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Analytics statistics should display the correct date-specific value for each date
- The Audience overview chart should label the “Previous month” series as “Previous period” (widget/area titles already have the duration)
- The series referenced when hovering an individual node in the “Previous month” series, should be labeled as “Previous period”.
Implementation Brief
In assets/js/modules/analytics/util/index.jsmake the following changes:- Extract the year, month and day from
dateString - Adjust the month to be zero-indexed.
- Pass the values
new Date( year, month, day)to get the correct date.
- Extract the year, month and day from
- Merge #1395
QA Brief
- Go to the Analytics screen in Site Kit
- Hover over any date on the blue line to view User count for that day.
- Compare the same date in the Analytics account to confirm that the day is displaying the correct User count for that day.
Changelog entry
- Fix Analytics data displayed for Users being partially incorrect due to incorrect date parsing.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)

Top Related StackOverflow Question
@ryanwelcher would you please add an IB for this since you’re the most familiar with the code here?
@aaemnnosttv 👍