Why does the Google Analytics API method return less data than web ui - google-analytics

Do the Google Analytics API methods allow to get the same amount of data, that is accessible through the web UI?
The problem is, for example, that in browser I can see more that 3000 lines in a report, but the API method returs only several hundreds.
Here is a URL for API method that I use:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A73XXXXXX&dimensions=ga%3ApagePath%2Cga%3Akeyword&metrics=ga%3Avisits%2Cga%3AvisitBounceRate&sort=-ga%3Avisits&start-date=2015-09-01&end-date=2015-09-30&start-index=1&max-results=3000

The API method you are using has queries appended on it. (Everything after the '?' and seperated by the '&') These are not part of the URL but actually information that is used by the server to customize your result. By changing the URL to say: https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A73XXXXXX&dimensions=ga%3ApagePath%2Cga%3Akeyword&metrics=ga%3Avisits%2Cga%3AvisitBounceRate&sort=-ga%3Avisits&start-date=2015-09-01&end-date=2015-09-30&start-index=1&max-results=10000 , you should get more results in your response. You may also want to change the start and end date, just make sure to keep the YYYY-MM-DD format.

Related

Purpose of tilde delimited values in URL fragment instead of GET params

I came across an unusual URL structure on a site. It looked like this:
https://www.agilealliance.org/glossary/xp/#q=~(infinite~false~filters~(postType~(~'post~'aa_book~'aa_event_session~'aa_experience_report)~tags~(~'xp))~searchTerm~'~sort~false~sortDirection~'asc~page~1)
It seems the category, pagination and sort options of a widget on the page injects and reads through these values. Does this format for storing data in the URL have a name, or is this an esoteric format someone made?
What's the purpose of doing this over using regular GET params, or at least using a more conventional format after the fragment?
If you inspect the URL carefully, you'll see that the parameters you describe are placed after the fragment (#), meaning they're not sent to the server but used by the client instead.
In this case, the client (JavaScript) builds them into something like an ElasticSearch query that's then POSTed to the server, in order to update listing you see on your screen.

Will Google Analytics treat url parameter as part of URL?

I need to incorporate my own parameters as part of url. (e.g. #student=DD&start=Date1&end=Date2). However, I am cerncerning about if I add my part to the url, will it mess up my google analytics tracking? Basically, now my url is something like -- MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC....
What url Google analytics will track? is my website url -- MywebsiteUrl, or ``MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2`?
Thanks in advance!
Google Analytics will treat query parameters as part of the URL. However it will not treat #student=DD&start=Date1&end=Date2 as having query paramaters. As far as (native) Javascript and the GA tracking code is concerned the URL ends after the fragment identifier (#).
So your complete example
MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC
you will get MywebsiteUrl?userID=AAA. If the userID parameter contains personally identifiable information you need to remove it to conform to Google's terms of service. You can use a filter or the exclude parameters-box in the view settings.

Paw app query request

Hi I am attempting to initiate a query to my backend on Kinvey which is backed by a MongoDB. They require passing URL parameters as such:
?query={"firstName":"James"}
I have tried every imaginable way of setting up these parameters in PAW but either get a success response with no filtering of the data or an error message of URL not supported when I try using a Raw Query String.
I have ran the query using their (Kinvey) backend API interface and it works fine in filtering the results so the problem definitely lies within PAW. I am currently using version 3.0.9. Any suggestions or is this just a bug that needs to be fixed?
Thanks!
I've just tried this setup in Paw and I have a few recommendations:
Paw will URL-encode the chars { and " as you can see if you open the HTTP preview in the bottom panel
Trying to send a similar query via Chrome (to test with another app to make sure Paw behaves correctly), I see that the query is URL encoded (try this query https://echo.paw.cloud/?query={"firstName":"James"} you'll see that the browser actually URL-encodes the characters { and " when sending. So the behavior is the same with Paw.
I don't think these two chars ({ and ") are valid HTTP if they are not URL-encoded, so I'm sure your server is expecting them encoded anyway
Testing this exact query in Paw, works for me, so please try these exact steps: go to URL Params, in the first column enter query and {"firstName":"James"} in the second column. Then using the HTTP preview mentioned above, make sure Paw is sending the request you're expecting.
Lastly, it's more like a tip, but as your value is JSON, I recommend that you use the JSON dynamic value to generate the JSON. It will be visually better for you, and will make sure you send valid JSON. For that, right click on the value field, and select Values > JSON. Here's some example:

Does Google Analytics Destination Goal Tracking match query params?

I'm investigating Google Analtyics Goal tracking. I would like to append a query param to specific urls to indicate goal completion. Eg.
/some/path?goal=goal_name
I do not want to use the path part of the url for matching, only the query param. If I setup a destination regex matcher, will Google Analytics match the param part of the url? Eg.
goal=goal_name
Yes, it does. If you use regexp as match type remember to escape your question mark if you use the full url (i.e. /some/path\?goal=goal_name).
You can actually test this easily - the realtime reports have a "conversion" menu item that shows goal conversions immediately (not e-commerce-transactions, though). I usually create a separate view to test new goals and filters so I don't mess up my live data - I recommend you do the same.

Google Geocode API "REQUEST_DENIED" in JSON response - reverse geocode action

Looked everywhere — and have read dozens of other questions regarding Google APIs (Maps, Geocode, Places, Autocomplete, etc) — and nothing has worked.
I have an API key with Places, Static Maps, and Maps v3 & v2 services enabled.
I am trying to perform a reverse geocode (get street address information via JSON from lat/long coords).
Here is the URL I am passing in my JavaScript (last 5 digits of API key replaced with #####:
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true&key=AIzaSyDbfv8bFidX1hSbXwwKTTxWQYgU7g####
The JSON response is:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
As you can see, there is a "sensor=true" parameter being passed - which is the problem according to the Google Document supporting this API, but that is clearly not the case here.
I also tried passing simply
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
which returns expected JSON response when the URL is entered into the addressbar of a browser — but when added to the JavaScript in my HTML file, I again receive:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
Any assistance is welcome, and greatly appreciated.
Google don't particularly want you to use this static API in a web page. You should be using the Maps API in a web page, and its associated geocoding functionality (because you need to show the results on a map anyway). These static APIs are intended for use server-side, so it looks like they now refuse requests which come with an HTTP_REFERER header.
(Using the key server-side allows you to keep track of statistics, but an invalid key will always result in REQUEST_DENIED whether there is a referrer header or not.)
I kept struggling with the exact same problem and I believe I came up with a very practical solution, which actually works just fine with me! You just have to make a small modification to your request query's URI.
Instead of querying the
http://maps.googleapis.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
you should actually query the google maps api using the following URI:
http://maps.google.com/maps/api/geocode/json?latlng=49.8925136,-97.1466635&sensor=true
That small modification did the work for me like a charm!
Hope this helps.

Resources