Sending events to 3rd party domains with Google Analytics Universal - iframe

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.

Related

Google Analytics Measurement Protocol events sent via REST API are not seen on the dashboard

I am trying to use the Google Analytics Measurement Protocol to record some events happening on my server-side code. I am using the REST API as suggested here but I don't see any events on the Google Analytics dashboard.
When I try to add the event via the Google Analytics Hit Builder, then I am able to see that event in the dashboard.
I don't think any authentication is required while using the REST API and only a correct tracking ID is required which is present. I have confirmed that the POST request is not failing.
I am looking at the Realtime > Events to check whether the events are pushed or not. Is there a place where I can check the historical data to see if the events are present there.
Thanks!

Google Analytics Tracking Events

In our Google Analytics, we have a couple of events showing up that we have not set them up! By that, I mean, I haven't trigger those events from our website, neither through codes (ga.send('event')), nor through Google Tag Manager. I just can't figure out where they're populating from. To be specific, they're "Video" and "Livechat" events.
Is it possible that Analytics have ways of figuring some obvious events and track them for us?
Google Analytics does not send events on it's own. More likely scenarios are:
You are using third party integrations for video and livechat and
they include Google Analytics code that sends to your property (and
possibly others)
Someone else is using your tracking id in their site (you can check this by setting hostname as secondary dimension in your event reports)

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.

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

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