Google Analytics Reporting API & Search Console - Dimensions & Metrics - google-analytics

As the Google Search Console is now fully integrated into GA...
(...see http://searchengineland.com/google-search-console-metrics-now-deeply-integrated-google-analytics-249334 ...)
...we would like to get access to e.g. the search terms via API (e.g. to access the data via spreadsheets). Therefore we want to know if this is possible at all - and if yes, which dimensions & metrics can be accessed.
The corresponding API page doesn´t help atm:
https://developers.google.com/analytics/devguides/reporting/core/dimsmets#cats=page_tracking,content_grouping,channel_grouping
Cheers!

There are two ways.
The first solution you posted yourself. The developers.google.com link is showing you exactly, what dimensions and metrics can be combined.
Try it yourself with the query explorer: https://ga-dev-tools.appspot.com/query-explorer/
Just add the metrics/dimensions you could probably need and try out what works.
If you need Search Console Data you should use the Search Console API ;)
There you go: https://developers.google.com/apis-explorer/#p/webmasters/v3/
The GA interface can show you the data, but GA is not the source of the data. And they also don't have a copy of it. You will need to use the right api.

Related

where to find google analytics dimensions values

I'm trying to implement my own google analytics reporting UI where users pick metrics and dimensions and then pick the filters according to what the user have already chosen and my question is there any way to get all the dimensions values? for example the dimension "country" can take the value of all the countries(USA,Fance,etc...). I've did some research on google but found nothing. any help is appreciated!
I would suggest using something like Analytics Edge extension for Excel to do exactly what you're trying to do.
If that doesn't completely solve what you're doing, the extension does pull all the pullable fields from GA. It also gives you an insight into what kind of request it sends to G to pull the data. Very useful for debugging, but also for learning the reporting API.
Alternatively, there's documentation on the API here: https://developers.google.com/analytics/devguides/reporting/core/v4
Make sure you know whether you're using GA4 or GA UA. They have different APIs.

Google Analytics API get Goal name

I need to get a goal name using google analytics API. I'd like to display this name along with some dimensions such as ga:goalCompletionsAll, ga:goalValueAll but I'm unable to.
I have done some research and all I could find are the explanations here Not getting Goal name using Google Analytics gapi but I'm using coldfusion and http requests to make the API call.
I know that I need to use the Management API to get the goal names and the Core Reporting API for other dimensions. I've done the API calls for both and looked at both responses and I'm unable to connect both results i.e the goal name and dimensions.
Kindly assist and thanks in advance
The reporting API doesn't return the name of the goal. You will need to go though the Management API.
goals.list returns a list of goals for the authenticated user. Then you can check if the goal nr is 1 what the name of it.
Note: Remember goal names can change over time so you cant really store these.
You should have two lists your the metrics you are requesting and the results of the goals.list. Currently there are only XX goal columns for metrics this may change in the future who knows. You will need to test your metrics to find out which number they selected. Depending upon what your application is allowing you can end up with several goals selected in one request.
You want to look at goal.id and goal.name. Goal id is the number.
My application is C# so I cant really share with you how I am handling this.

Google Analytics API - Retrieve Index/Name of Custom Dimension or how many used up

I have a service that pushes data into GA Custom Dimensions/Variables. Before I push I want to know which Custom Dimensions are available to push to and I also don't want to duplicate so if I have the unique name (because I would create unique names) of a Dimension I can check that too.
Anyone know how this can be done? I have searched through the API docs and it doesn't seem like it's anywhere.
Any help would be appreciated!
Thanks!
You can use the Core reporting api to get the names of the dimensions Custom Variables or Columns - Dimensions & Metrics Reference Then select then you can run a request against it to see what values are already stored.
Make sure you look into a service account don't go with normal Oauth2.

Mixable metrics and dimensions in google analytics

I'm doing some complex reports for google analytics and would like to ask you if the following is possible. The client wants to have just organic data for a bunch of metrics. Like pageviews, visitBounceRoutes, etc. The query I ended up with is the following:
https://www.googleapis.com/analytics/v3/data/ga?dimensions=ga:source,ga:medium,ga:keyword,ga:day,ga:month,ga:year&end-date=2013-11-20&fields=columnHeaders/name,rows,totalResults,totalsForAllResults&filters=ga:medium==organic&ids=ga:79067749&metrics=ga:pageviews,ga:pageviewsPerVisit,ga:visitors,ga:avgTimeOnSite,ga:newVisits,ga:visitBounceRate&start-date=2013-10-20
However the response is as follows:
'{"totalResults":0,"columnHeaders":[{"name":"ga:source"},{"name":"ga:medium"},{"name":"ga:keyword"},{"name":"ga:day"},{"name":"ga:month"},{"name":"ga:year"},{"name":"ga:pageviews"},{"name":"ga:pageviewsPerVisit"},{"name":"ga:visitors"},{"name":"ga:avgTimeOnSite"},{"name":"ga:newVisits"},{"name":"ga:visitBounceRate"}],"totalsForAllResults":{"ga:pageviews":"0","ga:pageviewsPerVisit":"0.0","ga:visitors":"0","ga:avgTimeOnSite":"0.0","ga:newVisits":"0","ga:visitBounceRate":"0.0"}}'
Can the dimensions ga:source,ga:medium,ga:keyword be mixed with the above metrics? It seems they can't since if I omit them the API returns an array of values 1 per each day within the specified range.
Where can I find more information about this and what categories are mixable? https://developers.google.com/analytics/devguides/reporting/core/dimsmets just shows all the available metrics but do not explains how they are combined and which one would be valid requests. I'm new at the analytics API and would be great any kind of help or guidance
Thanks a lot
Google Analytics Query Explorer is your friend for playing around with analytics dimensions/metrics/filters ;-)
Try http://ga-dev-tools.appspot.com/explorer/?dimensions=ga:source,ga:medium,ga:keyword,ga:day,ga:month,ga:year&metrics=ga:pageviews,ga:pageviewsPerVisit,ga:visitors,ga:avgTimeOnSite,ga:newVisits,ga:visitBounceRate&filters=ga:medium%253D%253Dorganic&start-date=2013-10-20&end-date=2013-11-20&max-results=100
Some thoughts:
Those dimensions & metrics should work -- maybe there was no organic data recorded during that time range?
Try removing the ga:medium==organic filter and see what your data looks like.
Does the profile you're using (ga:79067749) have any filters on it? If so, maybe try a different profile that has unfiltered data. (Analytics best practices -- make sure you have a profile with no filters applied that captures all data.)
As Mike said, there is no problem with the combination of metrics and dimensions you are using.
If you are entering the URL query directly in the browser problem might be the lack of URL encoding in your query string. For example, you need to convert == to %253D%253D
For example, instead of ga:medium==organic, you need ga:medium%253D%253Dorganic
If you build your query in the Google Analytics Query Explorer as Mike suggests, you can grab the direct link to your report by clicking the link symbol in the upper left:

Google Analytics Custom Variable/Value Report (How?)

I was able to setup Google Analytics to send custom variables that I can track.
I'd like to generate a report with UserId / Value and Display all of the pages
that user viewed. (Similar to reports I have seen with IP address on one column,
and viewed pages on the other)
Custom Var 1 : label:'userId' value:'17' scope:'1' (from Chrome Analytics tool)
Google Analytics reporting is pretty complex, so I'm hoping I can get some suggestions on how to create such a report.
i'm battling through google analytics aswell it can be really useful but to get exactly what you want can take some time. This isn't an answer as much as its a list of a few links that i have used along the way and hope they help
http://ga-dev-tools.appspot.com/explorer/
In here if you put ga:source ga:referralPath ga:customVarName(n)
This stack overflow answer may also help
Create google analytics profile by filtering using a custom variable
i'll have to look into this myself when i m using custom variables but it look like the advanced segment section may be the way to go.
And you ve probably already seen this but its quite a nice article on custom variables
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
Let us know hwo you get on...
I think you're going to want to create an advanced segment including your custom variable. This should narrow the data to only that which includes the variable. You can then look at whatever reports you want within that segment.
Using regular expressions should let you better tune the scope of the segment.
You can do this easily in the Megalytic reporting tool. There are widgets that let you create reports which segment data by custom variable. For example, Traffic by Custom Variable, Conversions by Custom Variable. Disclaimer: I am a founder of Megalytic.

Resources