Querying Event Flow with Google Analytics API? - google-analytics

Using: Universal Analytics (analytics.js)
I am currently testing user experience across a site by triggering different events upon pageView. On a given pageView, multiple events may be triggered.
I am interested in determining what events (or sequence of events) may lead to a conversion being triggered. In the frontend, this can be achieved via Event Flow or Goal Flow visualizations. Unfortunately I could find nothing online regarding querying Event Flow specifically.
Is it possible to query Event Flow from the Google Analytics API? If not, are there any workarounds that would allow us to quantify impact from different flows?

There isnt a way of doing it with the API. I want to start by saying i havent tried doing this I am just going on what i would do if i did want to attempt to do this.
The flow apears to start with any of the normal dimensions country for example. My first idea was the ga:goalpreviousstep1 dimensiosn then i remembered they cant be queried with other dimensions.
I would look into ga:previousPagePath and ga:nextPagePath see what they come back with. queried along with your goal or event they might give you an idea of what the user was doing.

Related

Getting programmatic access to Firebase Analytics trending events

I have a mobile app which plays audio tracks. It uses Firebase Analytics to record events such as 'track names' played. Within the Firebase 'StreamView' one can access trending events and see which are the most popular tracks being played at any given moment. I would like to gain access to this list to and use it within my app to display a list of "tracks being played now".
I've looked into gaining access to Analytic trending event data and think Firebase Cloud Functions may provide a method of extracting the information I need. However, I'm not certain this is the correct, or easiest, method.
Could someone let me know whether extracting trending events is possible and, if so, point me in the correct direction?
Thanks
EDIT - Actually, there is a much better and easier way to get access to real-time events that have occurred in your app over the last 30 minutes. You can do so using the Google Analytics Data API.
Using the API you can filter through the event data for the past 30 mins, and inspect relevant custom dimensions on the play_track event for the track that was played (or provide a custom dimension filter to further specify the event data you get back).
This would be the ideal way to achieve what you're looking for. You might still want to use Cloud Firestore if you'd like to keep a longer record of trending tracks being played (e.g. in the last hour, last 24 hours, etc... though). Also note that the API is still in alpha.
-- END OF EDIT
Other Solutions
Option 1 - Use Cloud Firestore
This is probably the easiest solution - you can create a record of which tracks are being played whenever the event occurs by creating a simple collection in Cloud Firestore, and updating records for tracks being played there. It would require additional effort in logging and retrieving which tracks are played beyond just using Google Analytics, but should be straightforward to implement.
Note you'll probably want to check out the Firestore pricing guide first before selecting this option.
Option 2 - Using Firebase Cloud Functions
You can trigger a Cloud Function each time a play_track event is logged. The event will need to be marked as a conversion event in order for it to trigger a Cloud Function, and within the Cloud Function you can access the event parameters to identify which track is being played, and over time maintain a record somewhere for which tracks are being played to determine the most trending tracks. To maintain state you could use something like Firestore to keep track of which "tracks" are being played at the moment.
A couple of caveats about this approach:
You'll want to check out the Cloud Functions for Firebase pricing guide to make sure it falls within an acceptable range for your needs.
Cloud Functions triggers for analytics events currently only works for Android and iOS apps (no support for web apps).
Google Analytics triggers for Cloud Functions is currently in beta.
Option 3 - Using BigQuery for your analytics data
This option requires a bit more effort to setup, but you can export your Google Analytics data to BigQuery, and query the generated intraday tables to see which tracks are trending as well as a lot more additional insights.
The caveat with this approach are that you'll also need to check the pricing guide for using BigQuery to make sure it falls within your needs, and you'll need to make a call to execute the query and retrieve the list of tracks (or get a cached result).

Sending custom event data to Google Analytics

I need to track events in Google Analytics from a server through the Measurement Protocol. I can do this just fine, but my problem is that I want to send additional/custom data along with the event. Specifically, I want to send a UUID along with the event so that it is possible for me to fetch data from the Google Analytics API in the future and correlate events with rows in a relational database.
Is there any decent way to send custom data along with events? I looked at using the event value, but it must be an integer, and it is not intended for things like this. The event category, action, and label are reserved for other purposes.
I am not that proficient in Google Analytics, so the solutions off the top of my head would be:
Send an additional event containing the UUID in the event label or something like that. Seems like a bit of a hack/workaround to send two events, with one being used exclusively behind the scenes.
Perhaps using a custom dimension or metric. I am not 100% sure about the implications of this and if that's a decent approach or not.
So basically my question is: what would be the best way for me to send a UUID along with a Google Analytics event from a server, taking into consideration that I cannot use the event category, action, and label for the current event? Is there any other way in which I could link events retrieved from the Google Analytics API to rows in a database?
So let's say I trigger a "Completed Order" event to GA, and I also have orders in a MySQL database. So what I want to do, is to link an event to an order row in the database.
There are several things that you can do and it pretty much depends on what you want to do with the information you are storing. For starters, all your requests should include the uid field with the value being the user ID within your system. This way all Google Analytics data will be calculated on the same user. Note: this is an internal value used within Google Analytics and you won't be able to see it.
Second, I would create a custom dimension of the name user_id and store the user information in that. You will then be able to use this information within your reports to see what each user is doing. Note: it's against TOS to send user name, email, or any other PII (personally identifiable information) to Google Analytics. But you can send your internal user ID.
I have done both of these in the past and found it to work quite well.
More info on User-ID.

Tracking internal search results impressions while filtering bot traffic?

I have a search results page which can show between 25 & 100 results at a time
Would like to track impressions for each results set (not clicks)
Ideally I'd have a list of each result's ID that would get saved for each pageview (as well as the page or page type the impressions came from). Then I could aggregate this by ID by day
I had originally wanted to use Google Analytics for this, however I don't think I can add data to GA in this way (even Universal Analytics custom dimensions)
But I could be wrong? Perhaps I could add data to GA in this way?
GA Events might have been an option, but this would generate a lot of events; some 25-100 for every pageview! The amount of traffic I receive might make this method impractical
Note: One of my key reasons for wanting to use GA is that it seems to filter out most bot traffic; I've also done some manual profile filtering to catch a few more bots. Rolling my own solution might mean reinventing the bot-filtering wheel, something I'm not keen on
Perhaps there is another service that could be used and provide similar bot filtering behaviour?

Multiple references to a single google analytics account on one page

I'm trying to pin down the reason for a discrepancy in Google Ecommerce tracking for a client, with most reports reporting values about 10 times higher than they should be.
So far the only fault I've been able to find in the tracking implementation is that _gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
is being set twice, both times to point at the same account.
This seems like it might potentially mess up the tracking, but the analytics console I'm using is reporting normal beacon activity.
Does anyone know if this configuration has any effect on how Google reports data?
This won't bother Google, the second call will simply overwrite the first (would be different for trackPageView or trackEvent or other interaction calls, but not a problem when you set the account id).

Google Analytics reports wrong goal completions and events count

I have this GA-tracked application that is not counting all my events and goal conversions. Events are correctly displayed in the Real-Time chart, but the reports apparently discard some of them. My goal completion counts are being incorrectly reported, too - for example, in a given day my user registration goal displayed less than 20 goal completions but I had almost 100 new users.
I am using Universal Analytics and my pageview count is still low compared to the GA threshold.
Any thoughts?
I also found few bugs and especially some events not firing properly. Hence, I move to old code again. Even in old code,” doubleclick.js” code not working for some Event Tracking. After I replace the code with old” ga.js” file all the event functions start to work without any modifications to the source code. Please stick with the old code for next few months.
Just check Avinash website (http://www.kaushik.net) , as we all know he is the digital marketing evangelist for Google. He is still using the old ga.js code. This tells that this new Universal Analytics code have some hidden bugs and they are testing the code with user experience. Hence this is not the time to fully depend on Universal Analytics. Sooner they will come up with updates and then it will be ok to move to Universal Analytics.

Resources