Google event tracking (background events) - google-analytics

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 :)

Related

Google Measurement Protocol advanced e-commerce hits not showing up in Analytics

I'm having issues with tracking advanced e-commerce transactions through Google Measurement Protocol. I want to use this because we can track sales with the most accuracy if it is done server-side. So we take over the cid from the frontend and track a sale as soon as the payment has been done. I have done this before in the exact same way but for some reason it doesn't work this time, or only works around 50% the time, depending on the tracking ID we use.
I am sending the following payload to: https://www.google-analytics.com/collect (changede UA code for the example):
v=1&t=event&tid=UA-MYCODEHERE-1&cid=532571481.1547156684&el=91901.000001&pr1ca=weekendje-weg&ni=1&uid=1337&pr2qt=1&tr=64.65&pr1br=Some%20Location&pr2va=3%20dagen%20-%20Standaardkamer&pr2id=DRTA-4379&ea=purchase&pr1va=3%20dagen%20-%20Standaardkamer&cu=EUR&ta=Some%20Location&pr2ca=weekendje-weg&pr2nm=Some%20Location%20Somewhere&ec=checkout&pr2br=Some%20Location&pr1pr=158.00&pr1qt=1&ti=91901.000001&pr1id=DRTA-4379&pr1nm=Some%20Location%20Somewhere&pa=purchase&pr2pr=158.00&ts=0
This validates in the Hit builder and using the Debug URL, I log all outgoing measurement protocol hits and they are always triggered and always return a status code 200, I have enhanced e-commerce tracking enabled for the tracking id and no filters there (brand new Analytics account) but my hits never show up for this account in Analytics (even after waiting for days still no single measure).
I'm not sure what's going on, I did this before like this and it always worked fine. Am I missing something? I tried switching to measurement protocol via http or https, GET or POST, etc, it all doesn't help. I did have this exact code working for a older property but it wasn't reliably tracking all transactions, now it's just tracking none. I think I tried everything I could, is this a Google Measurement Protocol/Analytics bug or am I missing something?

Tracking offline conversions with Google Analytics

On a website with affiliate links, where there is no programmatic access to the conversion logs, I treat it as offline conversions.
My Setup
Online
A user visit my website, see the affiliated ad and a promotion view hit is being sent.
When the user clicks the ad, a promotion click hit is being sent and the user is redirected to another page on my site.
On the "redirection page", an product view hit is being sent, and the user is being redirected to the affiliation link, passing his Google Analytics clientId.
Offline
Once a week I download the stats from the affiliate program, which looks something like:
clientId visits conversions revenue
4444444444.3333333333 1 0 $0
1234567890.1234567890 1 1 $16.40
Then I use the Measurement Protocol to send offline events:
For each line of visit, I send a product click hit.
For each line of conversion, I send a product purchase hit.
My Problem
The conversion shows up on the eCommerce report:
Because the offline hits are being sent after the original session is already closed, a new session is opened which doesn't contain the info about the user.
So I can't see the conversion on the demographic report, for example:
Optional Solution?
I'm thinking of using the user-id feature of Google Analytics.
Even though the users are not identified, I can identify them by their clientId.
Sure, this is not what Google intended when they introduced that feature, but I believe it will solve my issue. I'm just not sure about the negatives.
My Questions
Any feedback on my setup?
Why is it even necessary to pass the clientId after the session is closed? what kind of information is being shared between the real session and the offline hit?
Is it a bad idea to pass the clientId as a userId to Google Analytics? Why?
Relevant Articles
A Comprehensive Guide to Tracking Offline Interactions in Google Analytics using the Measurement Protocol
Google Universal Analytics isn’t Linking Offline and Online User Properly
We were able to link offline action through as you did with measurement protocol but the problem is that those sessions are not included in demographic and age report.
Rather looking those report I used them to do segmented analysis E.g. pages they have look at, sources they used to come also I used it with attribution model to understand best channels to drive more conversions.
Yes you can use CID as a user ID but I haven't tried it with offline tracking. Share the result with us.

What might interfere with Google Analytics pageview tracking?

I'm using Google Analytics to send and track a registration goal, based on a custom pageview.
Basically, every time a user registers and gets redirected to dashboard, I trigger a custom pageview using JS:
ga('send', 'pageview', {page: '/gapv/registration/success'});
The tracking works. However, when I compare the GA tracking with the number of registrations from the database of my website, the GA goal completion always shows around 10% less registrations.
I checked the tracking on various desktop browsers, all seems to be fine. Additionally, I hear that content blocking on mobile browsers gets more and more popular.
Is it possible that browser content blocker plugins might block my custom pageview from being fired? I send the pageview on DOM ready.
What else might explain the difference between my DB results and the GA goal count?
Any ideas are very welcome.
Users can opt-out from Google Analytics
Depending on where your tracking code is placed users may leave the page before the hit registers with GA (i.e. users might leave before the DOM is ready - can you move your tracking to pageload ?)
Some Ad blockers block GA, too (some claim this is especially true if you use the "advertising features")
There might be occasional javascript errors that prevent tracking (or users do not have javascript enabled at all)
As a serverside mechanism your database will be more reliable. While you may be able to bring the discrepancy down to single digits it is not likely that the numbers precisely match (even if you do server-side tracking with GA via the measurement protocol you still have to respect user opt-out).

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.

Combining Google Analytics client- and server side tracking

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.

Resources