Using the Google Analytics Export API to Trend Website

I’m working on an application that uses the Google Analytics Export API and am trying to get the “Trend” result that Google shows against each account on your site as a percentage.

those. UP 35.04% or DOWN 16.02%

How / where they get this number and whether the API is available in it.

I tried to compare the average values ​​for the last month with this month / first week of the period against the last week of the period, etc., but I can’t get the same numbers that Google provides.

any ideas?

thanks in advance Doug

+4
source share
1 answer

The formula is quite simple (with the exception of today's data):

(Visits from the last 30 days - Visits between 31 and 60 days earlier) / (Visits between 31 and 60 days ago).

You can see it in action in the interface if you go to the default control panel, where it shows you the last 30 days, then on the calendar click “Compare with past” and select the default value. It will show you the numbers used for each calculation and calculations, as they appear in this list of accounts.

However, the API does not expose pre-calculated numbers (for example, they do not calculate the bounce rate for you, they just give you pieces for it.)

So, you need to make two API requests to get this data. One for ga:visits for the last 30 days, and then for ga:visits 30 days before.

Then, when you receive it, simply subtract, divide and multiply by 100, and you will have the percentage that you are looking for.

UPDATE: The response part of the answer was true, but it is no more. The new version of the Google Analytics API provides access to some pre-calculated values.

+7
source

Source: https://habr.com/ru/post/1334491/


All Articles