Get Google Calendar Events from multiple accounts - google-calendar-api

I have a use case to get the data of google calendar events from multiple accounts that are signed in by the user and show all these data in a single calendar. Is the possible by the APIs provided by Google?

The only way you could merge two users calendar data into a single calendar would be to read the calendar data from the first user and insert it into the single calendar one by one though the API using event.insert.
You would need to monitor these calendars all the time as if a user changes the calendar on their original account you would need to export that over to the single calendar, you could set up push notifications though and google would inform you when there are changes to events.

Related

How to get user information for specific events in Google Analytics?

We have set up Google Analytics on Requestly Pricing Page. We are already getting site-related information, anonymous statistics, events from the page like
Pricing Page viewed
Coupon Applied Successfully
Duration Changed to Monthly
Premium plan bought
.. so on ..
However, Now we want to track the users who are performing a specific event like
Pricing Page Viewed
but did not purchase premium plan So that we can send targetted emails to those users. If we can get the user IDs (non PII data) from Google Analytics for a particular event, we can map them from our CRM system and get their emails and send them an email.
So, How can we get the list of users associated with some event?
If you are sending the information to Google Analytics as a custom dimension, simply add the second dimension in the Event report.
If you are sending the userId with its defined parameter you have to enable User-ID in your Property and create a User-ID view to see the data in your Analytics reports: https://support.google.com/analytics/answer/3123666?hl=en
Yes we have started sending User Ids to Analytics and now we are able to see User performing events in User explorer but I would like a reverse way. Given an event I want to know which users performed that event.
User ID in Google Analytics
There are three ways to import the User ID in Google Analytics:
customizing the schema field userId
setting up a custom dimension which contains the value
both of the above
In case 1, you can access the data via Google Analytics in User Explorer report, setting up a User ID View.
In case 2, you can access the data in each report that allows to define a secondary dimension.
In both cases, you can access the data in Google BigQuery, if you set up the export.
About your specific need
To know which users performed a specific event I suggest you to create a custom report in which you specify the event in the filters and you set your User ID custom dimension as dimension. This approach of course assumes that you import the User ID at least as a custom dimension.

Can we get events for multiple calendar id's using Google Calendar API?

Right now Google Calendar API has list API which takes calendarId and provides us with events of that calendar.
I have a scenario where I need to get events for multiple calendar Id's.
Instead of looping over multiple Id's and requesting calendar events n number of times, can I just pass multiple Id's in one request and get their events ?
Not sure if they have API support for this scenario.
No the API does not support this, each API request is paired with its unique keys that grant them access to one account, each token has the ability to only request connection from one account, so the only option is to iterate through each ID individually, this would be true for almost all API's of webservers.
The same goes for Calendar ID, in the API call, Calendar ID can only be a string and in the backend that string is matched with users Calendar Id, so any attempt to add multiple Id's will result in breaking the entire query.
events = service.events().list(calendarId='primary', pageToken=page_token).execute()
In this CalendarID has to be a string that is matched with the database.
The biggest reason for this would be that this is a very unique problem-solution and they might not have an incentive to support this feature as this does not make sense form a business perspective.

GA 360 export to Big Query

We have just linked our GA360 account to BigQuery but we noticed from the docs that the userId doesn't get exported. This is really annoying as one of our main use case was to join the userId with our CRM system.
Why is Google not exporting the userId ? Is there workaround ?
Thank you for your answers.
The solution is to create a User level custom dimension and pass your user's ID into that as well.
There's no restriction on exporting your custom dimensions, and these are exported to BigQuery.
Enjoy :)
How User-ID works
User-ID enables the association of one or more sessions (and the activity within those sessions) with a unique and persistent ID that you send to Analytics.
To implement User-ID, you must be able to generate your own unique IDs, consistently assign IDs to users, and include these IDs wherever you send data to Analytics.
For example, you could send the unique IDs generated by your own authentication system to Analytics as values for User-ID. Any engagement, like link clicks and page or screen navigation, that happen while a unique ID is assigned can be sent to Analytics and connected via User-ID.
In an Analytics implementation without the User-ID feature, a unique user is counted each time your content is accessed from a different device and each time there’s a new session. For example, a search on a phone one day, purchase on a laptop three days later, and request for customer service on a tablet a month after that are counted as three unique users in a standard Analytics implementation, even if all those actions took place while a user was signed in to an account. While you can collect data about each of those interactions and devices, you can’t determine their relevance to one another. You only see independent data points.
When you implement User-ID, you can identify related actions and devices and connect these seemingly independent data points. That same search on a phone, purchase on a laptop, and re-engagement on a tablet that previously looked like three unrelated actions on unrelated devices can now be understood as one user’s interactions with your business.
From Google analytics about the userid feature the user id is used in the background by google analytics to analyse your data.
If you want to analyse on the user id you can just add it as a custom dimension you will then be able to see it.

Sending custom event data to Google Analytics

I need to track events in Google Analytics from a server through the Measurement Protocol. I can do this just fine, but my problem is that I want to send additional/custom data along with the event. Specifically, I want to send a UUID along with the event so that it is possible for me to fetch data from the Google Analytics API in the future and correlate events with rows in a relational database.
Is there any decent way to send custom data along with events? I looked at using the event value, but it must be an integer, and it is not intended for things like this. The event category, action, and label are reserved for other purposes.
I am not that proficient in Google Analytics, so the solutions off the top of my head would be:
Send an additional event containing the UUID in the event label or something like that. Seems like a bit of a hack/workaround to send two events, with one being used exclusively behind the scenes.
Perhaps using a custom dimension or metric. I am not 100% sure about the implications of this and if that's a decent approach or not.
So basically my question is: what would be the best way for me to send a UUID along with a Google Analytics event from a server, taking into consideration that I cannot use the event category, action, and label for the current event? Is there any other way in which I could link events retrieved from the Google Analytics API to rows in a database?
So let's say I trigger a "Completed Order" event to GA, and I also have orders in a MySQL database. So what I want to do, is to link an event to an order row in the database.
There are several things that you can do and it pretty much depends on what you want to do with the information you are storing. For starters, all your requests should include the uid field with the value being the user ID within your system. This way all Google Analytics data will be calculated on the same user. Note: this is an internal value used within Google Analytics and you won't be able to see it.
Second, I would create a custom dimension of the name user_id and store the user information in that. You will then be able to use this information within your reports to see what each user is doing. Note: it's against TOS to send user name, email, or any other PII (personally identifiable information) to Google Analytics. But you can send your internal user ID.
I have done both of these in the past and found it to work quite well.
More info on User-ID.

How to efficiently retrieve events from multiple google calendars

Our scientists reserve time on 100 google calendars, which correspond to 100 scientific instruments at our laboratory. I display combined events for a scientist from all 100 calendars and display his/her events on a web page, so that the user can see at a glance upcoming reservations. I retrieve the users events from all 100 calendars by invoking EventsResource.CalendarService.Events.List(calendarId) per each calendar, but doing this 100 times is slow.
Is there a faster way to retrieve a particular user's events across multiple calendars without making a call-per-calendar as I do now? I realize I can embed the google calendar via iframe with multiple src's, but this UI calls for a tabular list and making a function call is more flexible than the embedded google iframe calendar.
If the user is creating the events, are the events showing on the user's calendar? If so, you can just retrieve events from the user's calendar, not each individual instrument calendar. If not, can you provide more details about how the events are being created, who owns them and who is invited?

Resources