Google Analytics API: Include profile domain in Profile Feed - google-analytics

Using the Google Analytics API I would like to display the domain associated with each GA profile. Is this possible or is there another way to do it? I have been unable to find any documentation for the domain.
http://code.google.com/apis/analytics/docs/gdata/gdataReferenceAccountFeed.html#accountResponse
http://code.google.com/apis/analytics/docs/mgmt/mgmtFeedReference.html#profileFeed
I can't use profileName because depending on how the user has their GA account setup, it may just be a string and not a domain.

One thing you might do is perform a query using ga:hostnames as the dimension and either ga:visits or ga:pageviews as metrics. This will yield a chart of the host name (what is in the browser address bar) to reach that site. Sort of a hack in a way. Technically you can use a single GA Tracking code on multiple sites. So there is no "Official" domain name associated with a profile.

Unfortunately, I don't think it's possible with the current API. Furthermore, you can't explicitly depend upon the domain they enter as the only domain the profile is tracking since there is further customization that allows the user to specify if they want to track subdomains and/or top-level domains. I believe your only option is to ask the user the same information Google asks the user and help the user understand they will have to manually keep two lists in sync due to limitations of the Google API.

Related

Exclude logged in cross domain tracked users

We have a CMS and a SAAS application, one is on .co.uk and the app is on .com
we have set up cross domain tracking in google analytics, so we can see the users interaction on both domains. What we want to be able to do in google analytics is exclude users that are a logged in.
it feels like we just need to add a custom variable to the gtag code in the head, but I can't find anything that feels like the correct way to do this. lots of articles talk about excluding based on a /login url.
Here you can find documentation on how to add custom dimensions and metrics with gtag.js: https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
You have to manage the code based on login (only when user is logged). Set the custom dimension with hit scope.
Then you can create a report applying a segment to exclude interactions or sessions that contain that dimension.

Can you implement google analytics with no domain binding?

We have a web service which is installed on different stations. Each has a different ip and domain. we want all of them to report to the same suite.
Can this be done?
The JavaScript tracker for Google Analytics can be used if you allow calls to the Google Servers, if you allow your clients to execute JS and either can set cookies or provide a client id in some other way (must not be personally identifiable data).
If you cannot use Javascript then you could still collect data via the measurement protocol, although this might require substantial development effort.
The domain setting in the Google Analytics interface does not affect data collection, it is used in the (soon to be removed) in-page analytics feature and as base url for the "open document" feature in the behavior reports.
Google Analytics does not collect by domain, but by property ID (UA-XXXXXXX-X), else cross-domain tracking would not be possible (it is actually a documented feature).
Cross domain tracking would be important if somebody could hop from one of your stations/domains to the other and you wanted this to be tracked as a single session. This does not seem to be your use case.
The only pitfall is that the reports display page paths, not full URIs. So if you have similar paths on all your stations the metrics for the page paths will be lumped together unless you do a breakdown by hostname. A common workaround is to add a filter to your data view that prepends the hostname to the path, or to provide custom paths in the first place.
But basically this is not a problem. If you do not need cross domain tracking you'll be okay if you dump the same tracking code in all your sites.

Allowing user access to analytics

I would like to enable (some) of my users to view my website's analytics data.
Our website has a bunch of groups where users can add content. I would like to enable certain users (group admins), to view usage statistics for that specific group. Ofcourse the data should only be accessable to those users with the VIEW_ANALYTICS right, not to any others.
Is there any way to do this in Google Analytics, or is there some other platform I could use to easily achieve this goal (we use AWS for our hosting)?
Regards,
klmdb
The Google Embed API allows you to display analytics data in your own pages. Pages that are only accessible to the members of your VIEW_ANALYTICS group.
You can create a service account and give it the appropriate access in the analytics user management for the property.
You also authorize the service account to use the embed API in the developers API console. (I don't have enough points to include more than two links in an answer.) In the API console you can generate a private key (p12 or json format) which you then use on your server to authenticate the request for analytics data.
You don't say which technologies you are using, but they show Java and Python examples of how to set up the authentication by the Service Account. I've also seen some node.js and php libraries.
This way you don't have to manage who has access through the google anayltics admin system, you just need to control who has access to your "dashboard" page.
I have done this all with client-side javascript and it works. Of course the client-side nature means that anybody who knows how to use browser debug tools can get our private-key, but in our particular case I'm not worried about it. On the other had it seem like you need to keep some security around this so I wouldn't recommend the client-side solution.

Separate analytics for each profile page within a single website

There are multiple profiles on my website and each user is managing his/her profile himself. I am trying to find the most efficient way to present analytics of each profile to its owner. Here are 3 ways I found:
Record each and every hit made on a profile page against that profile. This is not just count of hits, this requires to record IP, country, referrer, search terms etc. against each hit. This would require me to manage a huge database as there would be a lot of hits on each page. And a lots of processing on this database. Even if I have to de this, what database is recommended for such use?
Use Google Analytics on each page. But I am not sure that Google Analytics provide an API to fetch Analytics for individual pages.
Use some open source solution like piwik. Again I'm not sure if they provide per page analytics or not.
Please suggest the pros and cons of using each approach.
Update: More explanation - Think of it like a facebook page where each user can see hits on his page. What solution you'd suggest?
For Piwik, you can create a site id for each user, because you are allowed unlimited site ids with Piwik. You can can use a tracker with that user siteid, so when your member logs in, they get data only on their pages. You might also want to look at using custom variables and use the Piwik API to filter data.
Check here for info on multi-tracker: http://piwik.org/docs/javascript-tracking/#toc-multiple-piwik-trackers

Does google analytics combine naked domains with the www subdomain?

I have google analytics installed for my own domain, http://mydomain.com. Will a user that enters http://www.mydomain.com be counted by the analytics script too?
To me it seems logical that it would, since it is so common to have the naked domain address be the same site as the www-prefixed one, but the analytics documentation doesn't state it explicitly.
Yes, users will be tracked, but the same visitor coming from www.datalookups.com and datalookups.com will be counted as two different visitors. GA uses cookies to store session information on visitors, and since www.datalookups.com and datalookups.com are different hosts, different cookies belong to them. To get over this issue, I suggest to set up a proper HTTP redirection that brings permanently either user from www.datalookups.com to datalookups.com or vice versa—it's a matter of taste. (Not to mention that this method balks search engine crawlers to index your web content twice.)
For the sake of completeness, there is a way to tell Google Analytics to share session information between to different hosts with the pageTracker._setDomainName function, but that is not the right answer for the current situation.
Yes, that has been my experience.

Resources