从 Google Analytics Api 获取访问量变化

发布于 2024-12-06 10:11:21 字数 725 浏览 0 评论 0原文

我正在尝试从他们的 API 下载一些 Google Analytics 数据。 我可以下载我的访客号码。

当您使用 Google Analytics(分析)网页时,您可以看到访问量变化的百分比,但我如何从他们的 API 获取该信息?

Percents of Visits Changes

我可以尝试自己计算,但我不知道他们使用什么算法。

有关 API 的更多信息可以在此处找到。 数据 Feed 查询浏览器

编辑

Final formula
Visits over the last 30 days
StartDate = today.Year, today.Month - 1, today.Day
EndDate = today.Year, today.Month, today.Day - 1


Visits between 31 and 60 days ago
StartDate = today.Year, today.Month - 2, today.Day
EndDate = today.Year, today.Month -1, today.Day - 1

I'm, trying to download some Google Analytics data from their API.
I can download my visitors number.

When you use the Google Analytics webpage you can see a percents of Changes in visits, but how do I get that info from their API?

Percents of Visits Changes

I could try to calculate it by my self, but I have no idea of what algorithm they use.

More info about the API can be found here. Data Feed Query Explorer

edit

Final formula
Visits over the last 30 days
StartDate = today.Year, today.Month - 1, today.Day
EndDate = today.Year, today.Month, today.Day - 1


Visits between 31 and 60 days ago
StartDate = today.Year, today.Month - 2, today.Day
EndDate = today.Year, today.Month -1, today.Day - 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝戈者 2024-12-13 10:11:21

引用我的回答此处< /a>,

公式很简单(不包括今天的数据):

(过去 30 天的访问量 - 31 至 60 天前的访问量)/
(31 至 60 天前的访问)。

如果您转到默认仪表板(其中显示过去 30 天),然后在日历上单击“与过去比较”并选择默认金额,您可以在界面中看到它的运行情况。它将向您显示用于每个计算的数字以及该帐户列表中显示的计算结果。

然而,API 不会公开预先计算的数字(例如,它们不会为您计算跳出率;它们只是为您提供相应的部分。)

因此,您需要执行两个 API 请求才能获得此数据数据。一份针对过去 30 天内的 ga:visits,另一份针对过去 30 天内的 ga:visits

然后,当你得到它时,只需减去、除然后乘以 100,你就会得到你想要的百分比。

Quoting from my answer here,

The formula is pretty simple (excluding today's data):

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

You can see it in action in the interface if you go to the default dashboard, where it shows you the last 30 days, then on the calendar, click "Compare to past" and select the default amount. It'll show you the numbers used for each calculation and the calculations as they appears in that account list.

The API does not, however, expose pre-calculated numbers (for example, they don't compute bounce rate for you; they just give you the pieces for it.)

So, you'd need to do two API requests to get this data. One for ga:visits in the last 30 days, and then one for ga:visits in the 30 days prior.

Then, when you get it, just subtract, divide, and multiply by 100, and you'll have the percent you're looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文