How can I display Google Analytics using the API in my website - google-analytics

I have a website where buyers and sellers are logging in using their unique id. They will be visiting various product pages once logged in. Using Google Analytics API, I would like to display the details of each buyer or seller, with the time they spent in a product page, the pages they visited, etc., in my website backend.
However I am not able to get the UserID, which is important to display the user name and other information, using the google API code.
The same details are visible when I download the data as an excel sheet from google analytics dashboard.
Is there any restriction in APIs that the UserID will be not passed?
How we can achieve this otherwise?

Related

Setup Google Analytics Goals with user session properties

I’m trying to set up some dashboard to track the page views of my customers and identify how many of them visit the website logged in, how many visit the website and have a plan subscribed (SaaS company) and how many visit a specific page and have a plan subscribed.
Is there a way to implement this in Google Analytics?
If you send these informations to Google Analytics (i.e. an event when user is logged) you can create segments and get them number.
You can find here how to build a new segment: https://support.google.com/analytics/answer/3124493?hl=en

Tracking individual user activity using Google Analytics and then showing suggestions

Let's say I have a restaurant-review website where users can post reviews about the restaurants they visit.Can I use google analytics to track the information that each user searches/accesses on my website and then show him information related to it? Also, I'd like to know if someone visits my website and browses through some reviews without logging-in and then logs in, can I track the review pages he browsed before and then show them to him as his recent views when he is logged-in using GA? If not, I'd like to know how I can achieve this.
You can track an anonymous user activity and then map them when the user loges in. To do that in the application level you need to have an activity table with the application and track the user activity. Once the user loges in you just need to update the identifier of the activity table with the user Id.
Details can be fond on this post.
Here is how to do it with Google analytics:
You might need to setup the analytics properly. Not sure about mapping the two user (anonymous and post login) data.

Can multiple Google Analytics account have same profile ID?

Is is possible that multiple Google Analytics accounts (e.g abc#gmail.com and xyz#gmail.com) have same profile(view) Id or is it unique across all the Google Analytics accounts?
I am sure that web property is unique (as it is used to collect data from web/app) across multiple GA accounts but I am not sure about the profile IDs.
Here is the use case:
I am developing the web application which allows any user on internet to authorise his/her GA account and extracts the data from GA. The web application uses GA Reporting API V4 and performs caching mechanism based on Google Analytics username (i.e. abc#gmail.com).
Now let's profile ID 123 from abc#gmail.com is shared with xyz#gmail.com and both the users wants to extract the same data for same profile 123 from GA. Now since the caching is done on GA Username, web application will consider it as two different requests but if caching is done on profile id, only one of the two requests will be considered as new request and the other will be served from cached result. That is why I need to know whether GA profile ID is unique across multiple Google Accounts or not considering profile ID is not shared with any other account.
===== Edit =====
I have asked the same question to Google Advertiser community. Here is the link for reference.
https://www.en.advertisercommunity.com/t5/Google-Analytics-Account-Access/Can-multiple-Google-Analytics-account-have-same-profile-ID/td-p/888552
Correction:
Google analytics accounts are not based upon a single gmail address.
When abc#gmail.com logs into the Google Analytics website they may have one or more Google Analytics Accounts listed. Google Analytics accounts can be websites or mobile data based. A user can be added to more then one Google analytics account.
Lets say abc#gmail.com has a website. Superwebsite.com they create a google analytics account for tracking of that website. Now abc#gmail.com would like to share the data in that google analytics account with a new employee xyz#gmail.com. abc#gmail.com simply needs to add xyz#gmail.com as a user and they both have access to the Google Analytics account.
Answer:
A google analytics account id looks like this 59183475 and yes is probably unique Globally across all google analytics accounts. Web properties are used to actually insert the data into google analytics and look like this UA-59183475-1 they are also unique globally.
There is no way to know for sure unless you ask someone at Google. However I suspect that profile id is some kind of composite primary key. being that it will be unique across account - web property - profile id. I have no way to prove that its just a guess on how I would create the database personally.

Track user activity using google Analytics

I am new to Google Analytics.
We would like the analysis of our data data to focus on specific brand promotion, in my application I have the data from twitter, facebook and instagram. I would like to track user activity and collect data on click event such as
Title of the post
date of the post
channel(twitter,facebook,instagram)
etc.
I want to use an application unique user id and analyze the data based on a specific userid.
I have read custom Variables in Google Analytics, but I am not sure about how much analytics will help me to tracked above information.
From the Google Analytics Terms of Service:
Privacy.
You will not (and will not allow any third party to) use the Service
to track, collect or upload any data that personally identifies an
individual (such as a name, email address or billing information), or
other data which can be reasonably linked to such information by
Google. You will have and abide by an appropriate Privacy Policy and
will comply with all applicable laws, policies, and regulations
relating to the collection of information from Visitors.
That being said if your website has a Userid that can not be used to directly map back to a user. You could place that user id into a custom dimension.
You need only configure it in your Google analytics account then add a tracking code like this to your site
ga('set', 'dimension1', 'XXXXXXXX');
Then you will be able to use user id as a secondary dimension in most of the Reports on the website.

Show Google Analytics Data to Users

I am building a website and every user will upload images. The users' images will have unique IDs. The users will have their own dashboard with analytics.
I want to provide every user with analytics data (unique visitors, page views, bounce rate, etc.) for their own information. I am thinking of using google analytics for this instead of building something on my own.
Can this be done through google analytics legally? Are there any restrictions on showing such analytics information directly to the user?
The legal restriction with the Google TOS is that Google must not have any way to connect collected data to an existing person ( "data which can be reasonably linked to such information by Google", TOS §7). You are allowed to store anonymous IDs that can be matched in your own backend to persons as long as they cannot be resolved to individual users by Google.

Resources