通过Google AnalyticsAPI获取媒体资源的基本网址?

时间:2011-09-12 19:24:03

标签: google-analytics google-analytics-api

我正在使用Google AnalyticsAPI,并且正在从中成功提取大量数据。帐户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>

我以前一直使用<title>元素作为属性的基本网址,这通常有效,因为这是Google Analytics为该属性分配的默认标题。但是,如果用户编辑了这个(我正在查询我的最终用户的帐户,因此我没有控制权),就像“A Fifth Of Nothing”之类的东西,那么Analytics API将尽职尽责地将其作为标题返回我无法找到基本网址。

我搜索了Analytics API documentation并搜索了搜索结果,但是没有办法从Google Analytics获取网络媒体资源的基本网址。我尝试通过OAuth Playground查询id字段以获取更多信息,它只是给了我更多错误,说最后一部分必须是/default

有没有办法从数据API获取用户属性的基本URL?看起来这将是非常基本的东西。如果没有,我将不得不求助于尝试标题,如果它不像URL那样只是让用户自己输入,这不是非常用户友好,但这是我在这一点上唯一可以提出的

2 个答案:

答案 0 :(得分:1)

要使用的策略是针对ga:visit访问和排序降序对ga:hostname维度进行查询。您通常可以使用它来显示主机/基本URL。

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

答案 1 :(得分:0)

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