Can Google Analytics distinguish multiples requests using methods such POST, PUT, DELETE on a single URL? - google-analytics

I'm working on a web application that uses node.js + express. Our team has decided that all related pages must use a single URL and be distinguished only by its method.
So, for example: we have a group edition page. GET /groups gets the html, which includes the edition form, and POST /groups saves the changes.
The issue is that I only desire to track the POST /groups request. However, on the Google Analytics configurations, I only found URL-related tracking, nothing about specific HTTP methods.
Can this be done?

If you have implemented GA via the standard client-side tracking code then no, GA will not be aware of the http method (JavaScript has no access to http headers). It should however be trivial to render a Javascript if condition into the code depending on the request method.

Related

Tracking iframe origin

I am creating a Web Widget, a page that customers can use within an HTML Iframe in order to embed our experience on 3rd parties and vendors.
The site will be public, I am not willing to ask consumers to register in order to have a key or a unique identity to be passed as a query param for example (e.g. ?id=<unique_id>).
On the other hand, I need to track who is using the iframe. What are my options? A colleague suggested using the request headers, such as the origin, to track the usage on the server-side. Is that a good strategy? I'm not sure how much I can trust the origin header.
What if I fire an event (hence a client to server call), at page load (such as analytics) which logs the current page URL? Would that work, from within an iframe?
I am pretty sure I am reinventing the wheel here. What would be some good recommendations?
Thanks!
For others ideating for a similar solution, my fix was actually to simply hook a proper client analytics to the page, and trigger a page load event, upon page load, which would push not just the page, but quite a few other properties to our analytics.
Also, we added a clientId query param to our urls, so that we could identify precisely who was serving the iframe visited by the user.

How can I use Google Analytics without its gtag.js library

I am having some pages where I need to track page views and get data for reports. So I need to use some tracking events without using gtag.js.
I have tried solutions like GIF Request Parameters
But this solution was there in ga.js and its a legacy
The format used in your linked documentation is deprecated since Google introduced Universal Analytics in 2012.
However the current solution to send requests to Googke Analytics without a library, the Measurement Protocol, works broadly the same way. You have an endpoint (google-analytics.com/collect) and add the necessary parameters as described in the reference, depending on what kind of interaction you want to track. The endpoint returns a 200 http status and a gif (no matter if the request has actually been logged in analytics, this just confirms that you actually hit the server).

How can I get website analytics data of bots and users with no javascript and/or cookies?

Is it possible to get the info about website traffic without Google Analytics, for example?
For tracking without Javascript you can use the Measurement Protocol, i.e. you send a request to the Google Analytics Server with query parameter that specify the type of interaction (pageview, event etc) and the data you want to track.
General info is found in the protocol reference, a list of valid parameters is here, and if you want to test your tracking requests you can use the hit builder, which allows you to assemble, validate and send a hit to Google Analytics.
As for tracking without cookies that probably won't work very well. You need a persistent id to assemble hits into sessions, and sessions into visits. Such an ID is usually stored in a cookie (your "no javascript" requirement means that things like local storage are out of the question). You can either decorate all your links with a client id and use that to persist the parameter from page to page, or you use some sort of server-side browser fingerprinting.
All in all this might be somewhat less trivial than you assume, especially if you do not only want to track pageviews but also events that do not load a new page.

How to call Google Analytics script from dynamically generated ASP.NET MVC page

I have a number of cases in my ASP.NET MVC web app where I return a dynamic result (ContentResult which returns an rss feed in this case) from a controller action method rather than a view. In these cases how can I implement Google Analytics tracking?
You cannot include JavaScript-based tracking into RSS file, because as far as I can see from specification, there is no way to include JavaScript code/link into it.
As Matt explained, you need to use measurement protocol from Google or something similar and perform web request from your MVC action. This, however, will increase load on your web server. There are 2 other disadvantages with server-side tracking:
You will not be able to track additional information with this method like visit duration, bounce rate etc.
RSS is frequently downloaded by automatic tools and you stats will be very misleading.
You should consider those limitations when implementing your server-side tracking.

How to track RSS feed useage / views?

What's the best way to track how many times items in your RSS have been accessed?
Assuming your RSS is served from a webserver, the server logs would be the obvious place to gather statistics from. There are numerous packages for parsing and interpreting webserver logs.
AWStats is a popular (free) package, and Wikipedia keeps a fairly comprehensive list.
If you serve your feeds through something like FeedBurner then you can also get stats from there including clicks
You could use Google Analytics, but you would need a service to make the correct requests to the Google Analytics API or redirect to it. There are two APIs you can use:
the __utm.gif "API"
the Measurement Protocol API
To use the later (you need Universal Analytics), which is way better in my opinion, you would need to make a request or redirect to something like:
http://www.google-analytics.com/collect?z=<randomnumber>&t=pageview&dh=<domainname>&cid=<unique-client-uuid>&tid=<propertyid>&v=1dp=<path>
Where:
<randomnumber> is a random number to avoid caches (especially if you do redirects)
<domainname> is the domain name you see in your tracking code
<propertyid> is the property id you see in your tracking code (eg: UA-123456)
<path> is the path to the page you want to register the pageview for. Note that it must be quoted. Eg, for /path/to/page you would need to send %2Fpath%2Fto%2Fpage
I've implemented a simple redirector service that does exactly that here (explained at length here)
If you're stuck with the Classic Analytics then you would need to use nojsstats or the older implementation

Resources