【问题标题】:Getting the base URL for a property via Google Analytics API?通过 Google Analytics API 获取属性的基本 URL?
【发布时间】:2011-09-12 19:24:03
【问题描述】:

我正在使用 Google Analytics API,并且成功地从中提取了大量数据。帐户供稿 (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>

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

我搜索了Analytics API documentation 并四处搜索,搜索了 SO,但没有看到任何从 Google Analytics(分析)获取网络资源的基本 URL 的方法。我尝试通过OAuth Playground 查询id 字段以获取更多信息,但它只会给我更多错误,说最后一部分必须是/default

有没有办法从数据 API 获取用户属性的基本 URL?看起来这将是非常基本的东西。如果不是,我将不得不求助于尝试标题,如果它不像 URL,则让用户自己输入,这不是很友好,但这是我目前唯一能想到的.

【问题讨论】:

    标签: google-analytics google-analytics-api


    【解决方案1】:

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

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

    【讨论】:

    • 我将研究主机名维度。但是在每个配置文件的设置页面上(我的帐户中有多个配置文件,以上只是一个条目)有一个“网站 URL”字段,我希望我可以在:i.imgur.com/jPMgb.png
    • 我刚刚检查了一下,最后查询了 ga:hostname,度量为 ga:visits,按访问次数降序排序。这样我就可以选择最常见的主机名,以防万一出现异常情况。
    【解决方案2】:
    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多