Google analytics for multiple tenant tracking - google-analytics

I have a multi tenant setup using the same HTML but different web urls
eg. tenant1.company.com , tenant2.company.com
since both use the same htmls the analytics code is same. How do i set up different codes for different tenants to get different data in GA

Unless you intend to analytics between the two tenants you should be using a different web property id for each one. There is really no reason to be storing the data in the same Google Analytics account.
Its just a simple matter of changing the javascript snippet on each site.

Related

Google Analytics for website users

I operate a high-traffic website, where users have a public page (e.g. website.com/users/$USERNAME ) and would like to create analytics for them. Instead of re-inventing the wheel, the best would be if I could leverage google analytics directly.
It's not a problem is users opt-in to this scheme, and give me their google account name. One idea was to create custom analytics views for users, but it seems there's a limit of 25 views per properties.
Another thing I was looking at, is using Google Analytics segments, but it seems that segments are scoped to a subset of users or sessions, while I want it on certain page-hits only.
I could also dynamically use their google analytics code, if it was scoped to a single page.
Is this use-case something that Google analytics supports, or should I develop a home rolled solution?

Can I Get Individual Session Data from Google Universal Analytics?

I'm trying to add recommender systems to an existing website. In particular, I'd like to implement item-item collaborative filtering, to figure out what pages users tend to visit in the same session--much like Amazon's "People who viewed this item also viewed...."
At a minimum, collaborative filtering requires data on each individual viewing session, so that the algorithm can determine which pages get viewed together, rather than just tallying up how many times each page gets viewed in the aggregate.
If I were creating a new website, I could pretty easily add code to collect this data. However, this is an existing website, and has been set up to use Google Universal Analytics.
I have two questions:
Can I get Universal Analytics Data through an API? I need to be able to analyze the data using my own algorithms, not just look at it in a dashboard. I know about the Core Reporting API--but the Core Reporting API doesn't seem to include any extra Universal Analytics variables. I know about the API for sending Universal Analytics data, but that's not what I'm trying to do here.
Assuming I can query an API or otherwise export the Universal Analytics data, will I be able to distinguish individual sessions? The idea here is not to ask questions about individual users (let alone associate their data with some other data), but simply to figure out which pages were viewed in the same sessions.
Thanks for your help.
You can use the Google Analytics Core Reporting API many combinations of the available Dimensions and Metrics. You should check out the Common Queries page to get a sense of how precise you can get in terms of how people might use your application.
Also the Hello Analytics APIs Quickstart guide is a good place to start if you haven't developed an application with Google APIs.

Passing Google Analytics data from classic to universal

I need to explore the possibility of passing my existing GA eCommerce data (using Classic Analytics) over to a new universal analytics account.
I do not want to make the full switch as yet for various reasons. I do however want to use universal analytics to track newsletter email opens.
I would very much like to include the transaction data to this new universal analytics account so that I can put opens and revenue side-by-side. I know it is possible to aggregate analytics accounts to one profile but because classic and universal are different I wonder if there is any way we can aggregate data from Classic to universal?
Or do I place two tracking scripts on the thank you page?
Any tips or advice will be much appreciated.
From official help page "Set up Universal Analytics":
Best practices
If you want to try UA on a website you’re already tracking with Google
Analytics, we recommend you use the ga.js and analytics.js tracking
code concurrently to maintain continuity in your first account. Send
the data sets to separate properties: UA data to a dedicated UA
property, and ga.js data to a non-UA property. Data cannot be merged
or reprocessed after it’s collected. Alternative configurations are
not supported and can result in corrupted or incomplete data.
In the coming months, look for documentation to help you migrating
your existing Google Analytics web properties and data to UA.
So you can place two tracking scripts on the page.

How can I generate a GA tracking code programmatically?

How to generate Google Analytics tracking code programmatic-ally?
I am new to Google Analytics API, can someone please help
It is NOT possible to create new Google Analytics accounts or profiles programmatically using the existing APIs.
There are two APIs available, the Data Export API and the Management API. However, they are bot read-only.
With the Google Analytics Data Export API, you can develop client applications to request data from an existing Analytics profile for an authorized user, and refine the results of the request using query parameters. Currently, the Data Export API supports read-only access to your Google Analytics data.
Currently, the Management API supports read-only access to five components of the Google Analytics Management system: Account data,Profile data, Web property data, Goal data, Advanced segments
Seems like it's finally possible in 2021 with alpha api.
https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties/create#authorization-scopes
It's not currently possible to create Google Analytics accounts automatically at the moment but generating the tracking code is possible.
The only real variation between the tracking code generated each time you create a profile for a new domain is the web property ID. This is in the format UA-XXXXXXX-X. Each X is a number - the first 7 numbers are the account number and the number after the last dash relates to each web property set up for the account.
You can use the accounts feed of the API to get a list of accounts and their profiles. If an account only has one profile then it's possible to use the web property ID of it to automatically generate the tracking code. However, if there's multiple web properties then you would need a way to decide which one to use (present the user with a selection list etc).

Google Analytics - site with 2 domains, how to track each domain individually?

I have a website with 2 domains. I am trying to track the domains separately. I have both domains inside the same GA account - each domain has a filter applied to it to exclude the other's domain (both with and without the www). It looks like the domains are still being tracked together. How would I go about separating these 2 for different results?
Thanks!
What you're doing now is sending all the traffic to one account (say, UA-XXXX-1), and then using filters to separate them out. This is an imperfect solution, since filters have odd session-related quirks that make them less than ideal for tracking completely separate domains.
To completely separate the results, you need to create separate new web properties within your Google Analytics accounts , so that instead of tracking the second domain on UA-XXXX-1 and filtering, to send the data to UA-XXXX-2. It will roll up in the same area of your analytics account, but it will totally separate and segment the data.
You can read more about the organizational concepts here at this excellent Google Analytics Help Center walkthrough.
To set this up, you'll setup a new profile within the account and select "Add a profile for a new domain" as your option. There's a detailed walk through here.

Resources