pagePath dimensions yielding unexpected results from API queries in Google Analytics - google-analytics

I'm trying to use the GA API to run session queries that exclude certain page paths. I've tried using the following dimensions with varying levels of success, but am generally confused by the results.
pagePath
pagePathLevel1
pagePathLevel2
pagePathLevel3
Queries excluding visits based on pagePathLevel1 and pagePathLevel2 seem to yield expected results, but as soon as I use pagePathLevel3 it starts acting weird.
Example:
ga:pagePathLevel3==/page1/ yields no results
ga:pagePathLevel3==/page1/
yields the following:
desktop 882
mobile 124
tablet 38
Queries using regex and pagePath also act weird.
Example:
ga:pagePath=~/page/.*
yields the same result as
ga:pagePathLevel3!~/page/.*
I looked through Stack and the GA API docs and coudln't find anything useful on the subject. Any help would be greatly appreciated! I also tried including the hostname as a filter in conjunction with the pagePath dimensions with no improvement.

Related

Bing Web Search v7 Results Inconsistencies

I've been using the Bing Web Search v7 API for roughly about a month now and I'm starting to notice some obscure inconsistencies. Sometimes when I run a query, I get a JSON response with no results. I can then run the same exact query shortly after but this time the JSON returned will contain results. I'm not sure if I'm nearing my TPS limit (which is currently 100/s) but I don't believe I am. I also explicitly check for the URL length to ensure Bing doesn't return an error for a string that's too long. I'm doing queries in the same way that's described here. Each query contains a capture group with a set of terms "OR"'d together (which is done following the Bing advanced search guidelines). I had an issue with double spaces causing no results but that has been fixed. Is this possibly a result of the HTTP GET length requirements? Or maybe something wrong with my key? Any help is appreciated and let me know if any more information is required!

API requests for ga:pageviews metric returns too less results

I have a problem with the Google Analytics API.
I have two almost identical queries, the only difference is the selected metric (ga:pageviews vs ga:uniquePageviews)
the call for ga:pageviews return much lower totalResults than the call for uniquePageviews.
None of the queries use Sampling, so this should not be the Problem.
The otherwise identical Query with pageviews
At the bottom of the pictures you can see the total Results are much lower with the pageviews metric, but there shouldn't be any pagePaths that have uniquePageviews but no pageviews, so this data can't be accurate.
Am I missing something?
Can you help me get the correct numbers for the pageviews query?
Thanks!
Edit: Changing the date range or removing the filter does not resolve the problem
Edit2: after adding a sort by -ga:pageviews it looks like the results are grouped:
Hostname Page Pageviews
(other) (other) 204617
when I remove the hostname-dimension (and only use pagePath) this grouping does not occur and I get the complete list of URLs
I have no idea why the results are grouped, is there a way to prevent that?
Edit3: Looks like the results are thoses that have a session associated with them (Total results found: 1156 is the same number as a query for the ga:sessions metric returns) this only happens with pageviews (ga:uniquePageviews and also ga:hits returns all 200k+ rows)
Is this a bug or intended behaviour?

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:

Get more than 7 dimensions in google analytics

I am fetching my data from google analytics core api. I came to know that we can fetch only 7 dimensions using api, But here I need to fetch more than 7 dimensions with correct metrics. Is there anyway (other than using paid google analytics) to fetch more than 7 dmensions with correct metrics from google analytics.
If not, then is there any mathematical formula through which we can find intersection of dimensions fetched using 2 different dimensions having one dimension in common.
Thanks
The only way I have found around the 7 dimension limit is to be creative with filters. It will mean that you are sending more queries to the server, but if you aren't worried about your quota limit then its doable.
Example: ga:visitorType only has two values. New Visitor, Returning Visitor
So you could run a query with your 7 dimensions. Then add A filter ga:visitorType=New Visitor then run the same 7 dimensions with a filter added of ga:visitorType=Returning Visitor
Bingo you just got an 8th dimension.
Again you need to be a little careful because you are going to increase the number of queries you run by each value of dimension you are doing creative filtering on. I wouldn't recommend doing it with say ga:landingPagePath because the number of landing pages you have is to big. You will end up running too many queries. But there are a few you can do this with. ga:isMobile, ga:deviceCategory, ga:date. Just remember the more creative filters you add the more queries you end up running. I had one where I ended up expanding it to 80 requests just to get the data back I needed. Scary but it worked.
If you have specific dimensions that can be used to identify a session at a specific time (e.g. a session ID and browser timestamp), you can execute multiple queries then patch them together.
I built a python program that will do exactly this: https://github.com/aiqui/ga-download
This program can bring together multiple groups of dimensions, so that any number of dimensions can be downloaded and combined into a single CSV file.

Is it possible to segment visits by goal completions in Google Analytics?

I have a website, and want to use the Google Analytics API to give me data that only includes visits with a specific goal completion (say goal 2). I'm trying to use the ga:goal(2)Completions metric in a segment to get this data like this:
segment=dynamic::ga:goal(2)Completions!=0
However, whenever I try this in the Query Explorer I'm told this is an invalid segment value. I don't see goal(n)Completions as a disallowed metric for use in segments in the documentation (https://developers.google.com/analytics/devguides/reporting/core/v3/reference#segment), so what's the problem here? Is there a different way to get this data segment?
It is because of
you shouldn't use "segment="
(n) value should be with out brackets.
ids= ga:XXXXXXXX
start-date= 2012-01-01
end-date= 2012-01-31
metrics= ga:visits
segment= dynamic::ga:goal2Completions!=0
I have tested and the sample above should work fine.
And if you want to do the opposite use
segment= dynamic::ga:goal2Completions==0
You can double-check it by running the query without segmentation - both above should sum up the the latest one.
Cheers

Resources