通过 Google Analytics API 获取属性的基本 URL?

发布于 2024-12-04 03:11:04 字数 1771 浏览 1 评论 0原文

我正在使用 Google Analytics API,并成功从中提取了大量数据。帐户 Feed (https://www.google.com/analytics/feeds/accounts/default) 返回与您有权使用的帐户关联的网络媒体资源列表,格式如下 (大多数实际值被替换,不确定其中的敏感程度):

<entry gd:etag="W/&quot;<charsblahblahblah>.&quot;" gd:kind="analytics#account">
    <id>http://www.google.com/analytics/feeds/accounts/ga:########</id>
    <updated>2011-08-04T12:01:33.467-07:00</updated>
    <title>www.afifthofnothing.com</title>
    <link rel="alternate" type="text/html" href="http://www.google.com/analytics"/>
    <dxp:property name="ga:accountId" value="#####"/>
    <dxp:property name="ga:accountName" value="My Sites"/>
    <dxp:property name="ga:profileId" value="######"/>
    <dxp:property name="ga:webPropertyId" value="UA-#####-#"/>
    <dxp:property name="ga:currency" value="USD"/>
    <dxp:property name="ga:timezone" value="America/Los_Angeles"/>
    <dxp:tableId>ga:#######</dxp:tableId>
</entry>

我之前一直使用 </code> 元素作为属性的基本 URL,这通常有效,因为这是默认标题Google Analytics 分配给该媒体资源的信息。但是,如果用户将此内容(我正在查询最终用户的帐户,因此我无法控制)编辑为“A Fifth Of Nothing”之类的内容,那么 Analytics API 将尽职尽责地将其返回为标题,留下我无法找到基本 URL。

我浏览了 Analytics API 文档,并用 Google 搜索、搜索所以,但没有看到任何方法可以从 Google Analytics 获取网络属性的基本 URL。我尝试通过 OAuth Playground 查询 id 字段以了解更多信息信息,它只会给我更多的错误,说最后一部分必须是 /default

有没有办法从数据 API 获取用户属性的基本 URL?看起来这将是非常基本的事情。如果没有,我将不得不尝试标题,如果它不是类似 URL 的,只需让用户自己输入它,这对用户不太友好,但这是我目前唯一能想到的。

I'm working with the Google Analytics API, and am pulling a lot of data from it successfully. The accounts feed (https://www.google.com/analytics/feeds/accounts/default) returns a list of web properties connected to the account you're authorized for, in the following format (most actual values replaced, not sure how sensitive any of it is):

<entry gd:etag="W/"<charsblahblahblah>."" gd:kind="analytics#account">
    <id>http://www.google.com/analytics/feeds/accounts/ga:########</id>
    <updated>2011-08-04T12:01:33.467-07:00</updated>
    <title>www.afifthofnothing.com</title>
    <link rel="alternate" type="text/html" href="http://www.google.com/analytics"/>
    <dxp:property name="ga:accountId" value="#####"/>
    <dxp:property name="ga:accountName" value="My Sites"/>
    <dxp:property name="ga:profileId" value="######"/>
    <dxp:property name="ga:webPropertyId" value="UA-#####-#"/>
    <dxp:property name="ga:currency" value="USD"/>
    <dxp:property name="ga:timezone" value="America/Los_Angeles"/>
    <dxp:tableId>ga:#######</dxp:tableId>
</entry>

I've previously been using the <title> element as the base URL for the property, which usually works because that's the default title that Google Analytics assigns to the property. But if a user edits this (I'm querying my end-users' accounts, so I don't have control there) to something like "A Fifth Of Nothing", then the Analytics API will dutifully return that as the title, leaving me with no way to find the base URL.

I've scoured the Analytics API documentation and googled around, searched SO, but don't see any way to get the base URL of a web property from Google Analytics. I've tried querying the id field via the OAuth Playground for more info, and it just gives me more errors, saying the last part has to be /default.

Is there a way to get the base URL for a user's properties from the data API? It seems like this would be something pretty basic. If not, I'll have to resort to trying the title, and if it's not URL-like just have the user enter it themselves, which is not very user-friendly, but is the only thing I can come up with at this point.

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

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

发布评论

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

评论(2

情域 2024-12-11 03:11:04

使用的策略是针对 ga:hostname 维度执行 ga:visits 查询并按降序排序。您通常可以使用它来显示主机/基本 URL。

我不认为“基本网址”有这样的属性,因为从技术上讲,您可以将谷歌跟踪代码放在多个网站上。在这种情况下,您将有多个基本网址。

The strategy to use is to do a query against the ga:hostname dimension for ga:visits and sort descending. You typically can use this to reveal the host/base url.

I don't think there is such a property for the "base url" because technically you can put the google tracking code on multiple websites. And in this instance you would have multiple base url.

七婞 2024-12-11 03:11:04
View Full Page URL In Reports
By default, the data in your reports includes only the Request URI and not the domain name:

URL of page: http://www.example.com/foldername/page.html
Request URI: /foldername/page.html
Domain name: www.example.com

If you'd like to see the domain name as well as the Request URI in your reports, create an Advanced filter for your view with the following settings:

Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: $A1$B1

Note that creating URL rewrite filters like the one described above can affect Analytics' ability to match your goals properly.

If you're using Analytics filters to rewrite your URLs, you need to make sure that your goal settings reflect these changes. Like all filters, URL-rewrite filters are applied to the raw data coming into your account, before goals are processed. As a result, your goal and funnel URLs should reflect the final, rewritten format of the URL. For example:

If your site's URL:

/directory/download/file.html

is rewritten by a filter to look like:

/download/file

then your goal should match

/download/file and not /directory/download/file.html
View Full Page URL In Reports
By default, the data in your reports includes only the Request URI and not the domain name:

URL of page: http://www.example.com/foldername/page.html
Request URI: /foldername/page.html
Domain name: www.example.com

If you'd like to see the domain name as well as the Request URI in your reports, create an Advanced filter for your view with the following settings:

Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: $A1$B1

Note that creating URL rewrite filters like the one described above can affect Analytics' ability to match your goals properly.

If you're using Analytics filters to rewrite your URLs, you need to make sure that your goal settings reflect these changes. Like all filters, URL-rewrite filters are applied to the raw data coming into your account, before goals are processed. As a result, your goal and funnel URLs should reflect the final, rewritten format of the URL. For example:

If your site's URL:

/directory/download/file.html

is rewritten by a filter to look like:

/download/file

then your goal should match

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