There is some custom google analytics events I've specified for my application. Trigering these events is sometimes not very easy.
For example: User is redirected to home page after purchase and I have to forward some data that this home page is displayed after purchase to push something to _gaq
based on that.
Is there any way to trigger google analytics from backend e.g. in a controller without taking care if the action is ajax request or plain request and response has redirect or Ok status?
To trigger Google Analytics from the backend you should use: Measurement Protocol.
That is part of the Analytics Collection:
Web Tracking (ga.js) Measure user interaction with websites or web applications.
Android Measure user interaction with Android applications.
iOS Measure user interaction with iOS applications.
Measurement Protocol Measure user interaction in any environment with this low-level protocol.
At the moment it is available as dev preview. To signing up simply request access to the beta.