I use R Studio to export the necessary data from the GA4 property. I wanted to collect data on Google Ads campaign name, number of sessions and Google Ads clicks assigned to the corresponding campaigns. The number of sessions downloads to me, but it shows 0 Google Ads clicks, although I can see in the GA4 property that the clicks are there. Have you also had this problem? I am using the publisherAdclicks metric:
metric in R Studio API
I have not found any other metric through which I can retrieve this data, so do you have any idea what the problem is?
My code looks like this:
googleAdsSessionsClick <- google_analytics_set(c("sessions", "publisherAdClicks"),
c("sessionCampaignName", "sessionSourceMedium"))
I use my own function:
google_analytics_set <- function(choosenMetrics = NULL, choosenDimentions = NULL) {ga_data(webPropertyId,
date_range = date,
metrics = choosenMetrics,
dimensions = choosenDimentions)}
Related
Previously, with Universal Analytics, it was possible to request goal data via API by specifying the goal number, for example:
ga:goal01Completions
In GA4, assuming the event has been 'marked as conversion', this can be replicated by specifying the conversion name, for example:
conversions:online_enquiry
However is there are generalised method in GA4 which can request the count of any named event, regardless of whether or not it has been marked as a conversion, for example:
events:online_enquiry
events:page_view
events:begin_checkout
events:scroll
events:404_not_found
I used the runReport before.
https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
It's creating a report. Dimension is eventName and Metric might be eventCount or other you prefer.
Here is the list dimension and metric you can find
Metric
Dimension
But still open to better way maybe I don't know.
I need to filter Google Analytics MCF report by two basic product categories we sell (let's call them type1 and type2).
My current API call via R package RGA is:
get_mcf(profileId = 'xxxxx',
start.date = '2016-10-01',
end.date = '2016-12-31',
metrics = 'mcf:totalConversions, mcf:totalConversionValue',
dimensions = 'mcf:basicChannelGroupingPath',
samplingLevel = 'HIGHER_PRECISION',
max.results = 10000,
token = 'xxxxx')
With this I can get MCF paths for all products.
What I need to do now is to add filter or segment, which would allow me to add filter for product name, something like
ga:productName=#type1
How can I do this?
Thanks
there is a limited number of dimensions and metrics that you can use with the MCF api. As far as I can see there is no mfc:productName dimension
You can find the full list of dimenisons and metrics you can use with this api here Dimensions & Metrics Reference
I am trying to export Google Analytics data into R in order to build a report and do some other data mining related tasks with the data. I am using the RGoogleAnalytics package to do so. I have the connection working, but am having trouble specifying the correct query in order to obtain the right information.
I am trying to obtain information from a specific page that I would reach by going to the content drilldown section in google analytics, and searching for that specific page. I also would like to use a filtered view, to filter out ISP's that are from my work place. There are several websites under a particular view. To reach the specific page, I use the content drill down in Google Analytics. I am trying to build a query that pulls this information automatically. I have tried the following in regards to getting the correct query.
ValidateToken(token1)
query.list1 <- Init(start.date = "2016-10-28", end.date = "2016-12-05",
dimensions = "ga:date", metrics = "ga:uniquepageviews",
filters = "ga:pagePathLevel1
==/ed######.edu/;ga:pagePathLevel2==/content/",
table.id = "ga:##### ")
sort = "ga:date"
ga.query <- QueryBuilder(query.list1)
ga.data <- GetReportData(ga.query, token1)
This does not throw in error in R, but does not seem to be returning any metrics(it returns all zeros, for unique pageviews, when there are results) as shown below.
**date** **uniquepageviews**
1 20161028 0
2 20161029 0
3 20161030 0
4 20161031 0
In the above, I tried to use the filter to get the correct page. Is this correct? If so, what should I put into the filter so that it only returns metrics for a specific page in a given view? Also, is there a way to select for a given prebuilt view? Any help is appreciated, thanks.
Using R and the 'RGoogleAnalytics' package I have run into an issue of when running a query and the query in R not lining up with the table I get with the same segment in the Google Analytics report. I am using Google's Query Explorer to obtain the segment 'gaid', but I have also tried using the segment definition that the query explorer provides.
query.list <- Init(
start.date = "2015-5-1",
end.date = "2015-5-31",
dimensions = "ga:date",
metrics = "ga:users,ga:sessions",
segments = "gaid::...",
max.results = 10000,
sort = "ga:date",
table.id = "...")
ga.query<- QueryBuilder(query.list)
ga.data <- GetReportData(ga.query,oauth_token,
split_daywise = T)
The code runs, gives me a data frame, but the data frame does not match up with the tables I have with the same segment definitions in Google Analytics interface.
The segment of interest excludes specific users (defined by a custom user dimension), and has several session restrictions. The R code is is including extra users and sessions for some reason.
I've looked into the data trying to find out what users and sessions are getting through, but I am not finding any consistent trends between what is getting by the filter. Is anyone else running into this issue? Any suggestions?
I am pulling data programmatically from google analytics. This is the query I execute
def executeDataQuery(analytics: Analytics, profileId: String) : GaData = {
analytics.data().ga().get("ga:" + profileId,
"2012-01-01", // Start date.
"2012-01-14", // End date.
"ga:visits") // Metrics.
.setDimensions("ga:date")
.setSort("ga:date")
.setMaxResults(25)
.execute()
}
This gives visits/day. I assume the default granularity is per day.
How can I change the granularity of the data from visits/day to visits/minute or visits/month?
I know this can be done on the google analytics website.
There are quite a few ways you can slice up your data using the Core Reporting API Time - Dimensions & Metrics.
For instance, if you wanted to change it to hour, you could do:
.setDimensions("ga:dateHour")
If you'd like to preview the data that the api can get you, use the GA Query Explorer.