Cumulatively counting visits each day

13 views
Skip to first unread message

RG

unread,
Feb 10, 2012, 6:35:43 AM2/10/12
to google-analytics-api - GA Data Export API
Hi,

I'm working on a standalone app that displays the number of visits
each day. The actual app is more complicated, but the scenario below
illustrates the problem:

A couple of times each week the user launches the app and checks for
additional visits to his site, the visits are retrieved and added to
the total number of visits that I store on disk.

I fetch the visits by running a query like this:

metrics: "ga:visits"
startDate: DATE_OF_LAST_TIME_WE_CHECKED
endDate: TODAY

The problem arises if a user checks twice in a row on the same day.
The second check will have the startDate and endDate of TODAY. This
will correctly return the number of visits for today, but I can't add
them to the total each time to not count them multiple times.

I could change my application to not allow checking for visits more
than once a day, but this leads to another problem: what if the Google
Analytics data has not yet been updated at the time the user checks?
If he were to check again on the same day after the GA data was
updated the application would not allow fetching the data a second
time...

It gets even more tricky when taking timezones differences into
account.

I wonder if it is possible at all to reliably fetch and add up the
number of visits this way.

Does anybody have a suggestion how to approach this?

Thanks!
Rico






Reply all
Reply to author
Forward
0 new messages