- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
循环的功能完全不同,我不确定是否是因为使用了Google Analytics(分析)软件包,因为代码之间的差异很小。
打印语句输出中的WORK差异不会显示结果未正确输出。
library(googleAnalyticsR)
library(tidyverse)
#settings
start_dat <- as.character(Sys.Date()-31)
end_dat <- as.character(Sys.Date()-1)
#Authorize Google Analytics R- this will open a webpage
#You must be logged into your Google Analytics account on your web browser
ga_auth()
account_sum <- ga_account_list()
#Add the start and end date to the date frame, as well as some columns to use to populate the metrics
account_sum$start_dat <- start_dat
account_sum$end_dat <- end_dat
## choose the v3 segment
segment_for_call <- "gaid::-5"
## make the v3 segment object in the v4 segment object:
seg_ob <- segment_ga4("OrganicTraffic", segment_id = segment_for_call)
# cycle through the list of views, pull the data, and add it to the
#account_summary
for (i in 1:5){
view_id <- (Book1CSV[[1]][i])
views=view_id
ga_dat <- google_analytics_4(views,
date_range = c(start_dat, end_dat),
segments = seg_ob,
metrics = c("sessions", "pageviews"),
dimensions = c("year","segment"))
ga_dat <- summarise(ga_dat,
sessions = sum(sessions),
pageviews = sum(pageviews))
account_sum$sessions[i] <- ga_data$sessions
account_sum$pageviews[i] <- ga_data$pageviews
print(account_summary)
}
clean_sum <- select(account_sum,
ID = webPropertyId ,
Account = accountName,
Views = views,
Type = type,
Level = level,
'Start Date' = start_dat,
'End Date' = end_dat,
Sessions = sessions,
Pageviews = pageviews)
write.csv (ga_dat, "doesntwork.csv", row.names = TRUE)
library(googleAnalyticsR)
library(tidyverse)
#settings
start_date <- as.character(Sys.Date()-31)
end_date <- as.character(Sys.Date()-1)
metrics <- c("sessions", "pageviews")
dimensions <- "year"
#Authorize Google Analytics R- this will open a webpage
#You must be logged into your Google Analytics account on your web browser
ga_auth()
account_summary <- ga_account_list()
#Add the start and end date to the date frame, as well as some columns to use to populate the metrics
account_summary$start_date <- start_date
account_summary$end_date <- end_date
# cycle through the list of views, pull the data, and add it to the
#account_summary
for (i in 1:6){
view_id <- (Book1CSV[[1]][i])
ga_data <- google_analytics_4(viewId = view_id,
date_range = c(start_date,end_date),
metrics = metrics,
dimensions = dimensions)
# This query might return multiple rows (if it spans a year boundary), so
#collapse and clean up
ga_data <- summarise(ga_data,
sessions = sum(sessions),
pageviews = sum(pageviews))
#add the totals to the account summary
account_summary$sessions[i] <- ga_data$sessions
account_summary$pageviews[i] <- ga_data$pageviews
print(account_summary)
}
# Make a more compact set of data
clean_summary <- select(account_summary,
Account = accountName,
View = viewId,
Type = type,
Level = level,
'Start Date' = start_date,
'End Date' = end_date,
Sessions = sessions,
Pageviews = pageviews,
ID = webPropertyId)
select
write.csv (clean_summary, "worksfine.csv", row.names = FALSE)
Book1CSV
的文件,因为我无法获得可以捕获错误的try-catch语句。 Google商家商店的Beta版帐户导致了崩溃。
最佳答案
这是一种反R模式,可在循环中修改对象。最好返回data.frames列表,然后合并,最后创建摘要。
所以像这样:
my_view_ids <- c(12345,233445,232434)
## fetch data, create a list of
all_data <- lapply(my_view_ids, function(id){
one_data <- tryCatch(google_analytics_4(viewId = id,
date_range = c(start_date,end_date),
metrics = metrics,
dimensions = dimensions),
error = function(ex){message(ex); NULL})
one_data$viewId <- id
one_data
})
## Reduce the list of data.frames to one data.frame
all_dataframe <- Reduce(rbind, all_data)
### make your summary etc.
关于loops - Google Analytics(分析)自然搜索循环问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47088052/
最近,我收到了一个项目要求,即从某个页面将数据发送到Google Analytics(分析)。我不知道该怎么做。 帐户ID和所有内容均已创建,我只想知道如何在加载某个网页时发送数据。 我一直在根据自己
我试图在此站点和其他一些站点上找到此问题的答案。但这似乎并不适合我自己。以下网址显示了有关如何同时使用GA和UA的说明。 How to use both ga.js and analytics.js?
从谷歌的文档: The analytics.js snippet is part of Universal Analytics, which is currently in public beta.
根据google的新analytics.js文档,您可以设置多个跟踪器,并通过在单独的send调用中按名称明确提及跟踪器来向其发送事件: https://developers.google.com/a
有什么办法可以让 Google Analytics 的“In-Page Analytics”显示外部链接流量? 实际上,外部链接的综合浏览量会显示在流量报告中,但不会显示在页内分析中。 我们正在使用这
我正在尝试编写一个 Google Analytics API 查询,它只返回去年每个月的每月唯一身份访问者。 This is the data I see in the Google Analytic
我们在我们的应用程序中使用 Google Analytics,但现在我们需要更改它并改用 Adobe Analytics。 在对这两种工具进行比较研究时,我现在意识到了这两种工具的优缺点和特点,
我需要您有关 Google Analytics (analytics.js) 的帮助。我在头部有第一个通用部分,效果很好: (function(i,s,o,g,r,a,m
这个问题在这里已经有了答案: Why use protocol-relative URLs at all? (5 个答案) 关闭 5 年前。 我正在阅读 https://developers.goo
将目标从Analytics(分析)导入到AdWords中,然后在Analytics(分析)中更改目标条件时,是否可以通过更改将目标“重新导入”到AdWords,还是可以自动选择? 最佳答案 更改目标值
Google最近更新了他们对开发人员的政策。 https://play.google.com/about/privacy-security/personal-sensitive/ If your ap
我正在使用google analytics api来获取数据。我正在获取数据,但我想验证两个参数,它们在特定日期范围内始终为0。我正在获取['ga:transactions']和['ga:goalCo
我使用Google API从Google Analytics(分析)获取数据,但指标与Google Analytics(分析)的网络界面不同。 即:我在2015年3月1日获得数据-它返回综合浏览量79
我安装了 Google Analytics (UA) 并将跟踪代码添加到 html 页面。我从浏览器文件中运行 html 页面:///C:/test.html 并使用谷歌调试器进行调试,它成功运行并显
我正在遵循 https://developers.google.com/analytics/devguides/collection/amp-analytics/ 的简单指南 尝试添加 Pagevie
我计划管理大约。通过为每个属性创建带有主机名过滤器的专用 View ,可以在一个属性下创建 400 个差异站点。是否有任何流程可以在不手动创建 View 和制作过滤器的情况下完成此任务? 例如:我们有
我想使用 Google Analytics API 访问 User Explorer 数据,以获取 JSON 值形式的报告。使用此 JSON 值,我可以创建用于分析的 Web 应用程序仪表板。我在此
我正在尝试使用此代码来跟踪 Google Analytics 中的事件 _trackEvent(category, action, opt_label, opt_value, opt_noni
我目前正在使用访问 token 和刷新 token 从 Google Analytics Reporting API (v4) 中提取数据。当我致力于自动从 Google Analytics 中提取数
我正在尝试根据此相关问题实现 anchor (index.html#anchor)跟踪: How to track anchor tags with Google Analytics 我使用 anch
我是一名优秀的程序员,十分优秀!