Combining Google Analytics client- and server side tracking - google-analytics

I track my users behavior using Google Analytics client side. At some point the user is redirected to one of my partners and I receive a callback from the partner about the value the user has generated.
The question is: How do I append that value from the callback as a goal with a value to the users session?
The objective is to be able to get insights about which of my traffic sources generate the most value (and not just most conversions - as that could be tracked with event tracking).
The solution might be similar to this one, but I'm not sure it's still the best solution - and there could be others as well.
Using Google Analytics to track the same session in client javascript and server side tracking calls?
Thanks in advance.

So it seems that this is now possible with the new Universal Analytics from Google by saving/syncing the users UUID to the server and then tracking any relevant events.
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
This package seems like a nice wrapper: https://www.npmjs.org/package/universal-analytics

Another option is to use same userId (not clientId). That works for multi-device tracking https://support.google.com/analytics/answer/3123662
Universal-analytics is better in that you can use it for anonymous users as well as signed-in users
But tracking by userId is better in that you can send events even if user is not currently on your website doing http or websocket requests.

Related

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.

Tracking a clients QR Codes - Google Analytics

We would like to track clicks on QR codes on behalf of a client - they have their own analytics account - but we would like to track the clicks to determine whether a QR code is required on future campaigns.
We initially thought that we would provide a url to a page on our server which would track the click and re-direct to the relevant link - but we have also read about urchin tracking modules and wondered whether these could be used in this scenario instead as a less labour intensive method? Does anyone have any experience with this - if so could you advise on best practice?
Can anybody
You can track that by using a relatively new feature in Google Analytics: the measurement protocol. It allows you to send data straight to GA via HTTP requests.

Google analytics Embeded api with out Oauth authorize

How can i use gapi.analytics.auth.authorize without button..
I need it for customers, to track visits on their subdomain, and I have my analytics code on page, so they can't use button to authorize, need without it, automatically.
Any example?
Your question isn't very clear it is hard to understand what you mean by Button.
I think you mean that you would like to select data from YOUR Google Analytics account and display it on YOUR website.
To do this you will need to use a service account as apposed to Oauth2 (Oauth2 would popup with a new window requesting access). When you create the service account in the Google developer console take the service account email address. Give it access at the ACCOUNT level in the Google analytics admin section. It must be the account level this will then give the service account access to read your Google analytics data.
Quota: I am not sure what you are extending to do here but remember you can only make 10000 requests per day against your Google Analytics profile. After that you are cut off there is no way to extend this number. So I advice you to save the data in the database someplace you shouldn't request the same data more then once.
Example:
I suggest that you look for an example in what ever programing language you are intending to use. Again your question doesn't state anything about what language you will be using. Hello analytics API might be a good place to start but it depends upon the language the PHP one is way out of date I wouldn't bother with it. Also you cant use a service account with JavaScript so that one is out to.
Update figured out button
Embded api I think I have finally figured out what you mean by button. gapi.analytics.auth.authorize is used in the Google analytics embedded api. Which is JavaScript which it is not possible to use with a Service account. So the final answer to your question is
Answer: You cant remove the button from the Google Analytics Embded api the only way to login with JavaScript is to use Oauth2.
Advice: switch to PHP and use a service account to request data yourself. Or give each of your customers access to your Google analytics so they can login themselves.

Sending events to 3rd party domains with Google Analytics Universal

We provide an iframe-based embeddable widget to our clients and want to be able to send their Google Analytics account events based on what is happening inside our iframe. We used to be able to do this using the old ga.js with the following code:
_gaq.push(['NAMESPACE._setAccount', CUSTOMER_GA_ACCOUNT_ID]);
_gaq.push(['NAMESPACE._setDomainName', CUSTOMER_DOMAIN]);
_gaq.push(['NAMESPACE._trackEvent',"category", "event", "label"]);
This code would be fired inside our iframe, but would result in an event being pushed to the customer's google analytics account, letting them have some insight into customer behavior inside our embeddable widget. The NAMESPACE in front of the actions would keep these events separate from our GA stuff, and would prevent our GA stuff from going to their GA account. They would provide us with their Google Analytics account ID when they wanted to enable this feature.
Is there a way to do something similar with the new Universal Analytics API?
I don't seem to see a similar way to namespace actions and the cross-domain tracking documentation doesn't indicate how to send events/pageviews to two domains/GA accounts (ie we want to track pageviews on our GA account, and send the events to our customer's GA account).
I suggest going the roundabout way - set a pixel in your widget and make the actual endpoint for that pixel a script on your server that sends the data via the measurement protocol to your clients analytics account.

Google event tracking (background events)

Ok so here is a scenario I would like to get some ideas on:
A user shows up to my site and registers for my service...lets call the service "vaporware".
After registration the user proceeds to view all the glorious features that my cloud based vaporware has to offer. Each feature that they use during their visit is recorded using Event Tracking in Google Analytics and I can effectively track engagement.
Now the problem:
One of the features in my Vapor product has tasks built in. These tasks are important for a number of reasons...they are recurring and do not require any action from the user to execute.
How would I using either "old" google analytics or the new Universal Analytics go about tying these "background events" visitors? I am thinking that the new Measurement Protocol may be have the answer as this perhaps can be considered cross platform tracking...
Regardless this keeps coming up a lot for me and am interested even finding a hack/work around to start recording these types of events in GA.
If they're logged in, you can substitute the autogenerated client ID with your own user/account ID (make sure to anonymize it before sending it to Google).
With the Measurement Protocol it's the cid parameter:
...v=1&tid=UA-XXXX-Y&cid=my-user-identifier&t=event...
In the Universal Analytics JS code, it would be something like this:
ga('create', 'UA-XXXX-Y', {
'clientId': 'my-user-identifier'
});
Hope this helps :)

Resources