Google Analytics:如何获取页面类别(内容组)数据?

huangapple go评论65阅读模式
英文:

googleanalyticsR : How can I get page categories (content group) data?

问题

I am trying to get data on page categories from Analytics, but it seems that this variable does not exist, as looked on https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/.
如果您知道如何获取这些数据,那么其他问题就不适用。

If this indeed does not exists, those are the steps that I follow to get "grouped pages" data:
如果确实不存在,那么这些是我获取“分组页面”数据所采取的步骤:

  • In order to get page data, I use the dim_filter argument

  • 为了获取页面数据,我使用了dim_filter参数

  • I define all the pages I need in all.pages

  • 我在all.pages中定义了我需要的所有页面

  • The function (x) allows for the iteration over the different page names

  • function (x)允许对不同的页面名称进行迭代

  • The actual iteration is done with the map function where I pass all.pages through the function (x)

  • 实际的迭代是通过map函数完成的,我通过function (x)all.pages传递给它

  • Then, I create a dataframe

  • 然后,我创建一个数据框

  • Because the actual name of the page used in the regex is not in the dataframe, I add them with the mutate function

  • 因为正则表达式中使用的页面的实际名称不在数据框中,我使用mutate函数将它们添加进去

This works when there is no dimension but it is rather impossible to do with even a single dimension because the number of rows will not be the same as the length of all.pages.
这在没有维度时可以工作,但是即使只有一个维度也几乎不可能完成,因为行数将与all.pages的长度不同。

Would anyone know how to overcome this ?
有人知道如何克服这个问题吗?

Thanks in advance to all of you !
提前感谢大家!
Best, D.
最好,D.

英文:

I am trying to get data on page categories from Analytics, but it seems that this variable does not exist, as looked on https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/.
If you do know how to get this data, the rest of the question does not apply.

If this indeed does not exists, those are the steps that I follow to get "grouped pages" data:

  • In order to get page data, I use the dim_filter argument
  • I define all the pages I need in all.pages
  • The function (x) allows for the iteration over the different page names
  • The actual iteration is done with the map function where I pass all.pages through the function (x)
  • Then, I create a dataframe
  • Because the actual name of the page used in the regex is not in the dataframe, I add them with the mutate function
all.pages <- c("page.name.1","page.name.2","page.name.3")

pages.ga <- function (x) { x.pages <- dim_filter(dimension="pagePath",operator="REGEXP",expressions=x)

x.filter <- filter_clause_ga4(list(x.pages))
x.results <<- google_analytics(ga_id,
                               date_range = c("2019-09-01","2019-11-30"),
                               metrics = c("bounceRate","pageviews","avgTimeOnPage"),
                               dim_filters = x.filter,
                               max = -1)

}

list.pages.results <- map(all.pages,pages.ga)
df.pages <- dplyr::bind_rows(list.pages.results)
df.pages <- df.pages %>% mutate(page.name = all.pages)

This works when there is no dimension but it is rather impossible to do with even a single dimension because the number of rows will not be the same as the length of all.pages.

Would anyone know how to overcome this ?

Thanks in advance to all of you !

Best, D.

答案1

得分: 2

它存在于内容组

ga:contentGroupXX

其中XX是一个整数。为了让事情变得更简单些,您可以前往查询资源,在维度下输入内容组。您可用的整数将自动填充,您可以探索哪个整数是您要寻找的。

英文:

It exists under content group

ga:contentGroupXX

Where XX is an integer. To keep things a bit simpler, it would be easier if you go to query explorer and type in content group under dimensions. The integers you have available will populate and you can explore which integer is the one you seek.

huangapple
  • 本文由 发表于 2020年1月6日 23:07:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/59614443.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定