Event attendee ID missing on Google Calendar Events list response - google-calendar-api

The Google Calendar specifies that it will return an array of Event resources that will also include:
attendees[].id (string) The attendee's Profile ID, if available. It
corresponds to theid field in the People collection of the Google+ API
However, when I invoke the Events:list API it returns me an attendee with the following properties only:
{
"email": "attendee.address#gmail.com",
"displayName": "Attendee Name",
"responseStatus": "accepted"
}
I would like to fetch more information (and namely the user avatar) for this user/attendee by invoking the Google+ API, however, without an ID I can't do much.
The endpoint that I am using to fetch events is https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?${params} which I confirm is the latest API version.
Any thoughts on this issue would be much welcome!

Related

Google Calendar API - Clear all events

I'm trying to clear all the events of a google calendar using the calendar ID.
https://developers.google.com/resources/api-libraries/documentation/calendar/v3/python/latest/calendar_v3.calendars.html#clear
Attempting it, gives a "400 Bad Request" response from either Python or a simple curl call using the Google API Explorer:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
From either the API explorer or the python API I'm providing only the calendar ID of the corresponding (non-primary) calendar I want to delete.
In Python:
service.calendars().clear(calendarId=<calid-found-in-calendarList().list()>).execute()
Which returns:
<HttpError 400 when requesting https://www.googleapis.com/calendar/v3/calendars/<calendar-id>4%40group.calendar.google.com/clear? returned "Invalid Value". Details: "[{'domain': 'global', 'reason': 'invalid', 'message': 'Invalid Value'}]">
Any idea what I'm doing wrong?
When I had tested the clear method of Calendars in Calendar API v3 before, I had experienced the same situation with you. When I used the value of primary, no error occurs. All events of the primary calendar are deleted. But, when I used the calendar ID except for the primary calendar, the same issue occurred.
When I saw the official document, it says Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.. But about calendarId in this method, it also says Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword..
These documents consuse me. So, I checked this "clear" method at Discovery API. Ref It says as follows.
"clear": {
"parameters": {
"calendarId": {
"location": "path",
"required": true,
"type": "string",
"description": "Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the \"primary\" keyword."
}
},
"scopes": [
"https://www.googleapis.com/auth/calendar"
],
"httpMethod": "POST",
"id": "calendar.calendars.clear",
"description": "Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.",
"parameterOrder": [
"calendarId"
],
"path": "calendars/{calendarId}/clear"
},
From above document, I thought that the calendar ID can be retrieved by the calendarList.list method. But, this "clear" method might not be able to be used for the calendar except for the primary calendar.
And, when I saw the error message, when the calendar ID like ####group.calendar.google.com is used, the error of "message": "Invalid Value" occurs. But, when sample is used as the calendar ID, "message": "Not Found" is returned. It seems that the API might search the calendar. In this case, even when the URL encoding is used, the same issue occurs. From this situation, I thought that this might be a bug.
But, I'm not sure whether this is the current specification or a bug. So, I searched this situation at the issue tracker. But, unfortunately, I couldn't find the same issue. So how about reporting this at the Google issue tracker? Ref
Reference:
Calendars: clear
Something to add to this when I encountered the same issue. Seeing that clearing secondary calendars of events is not currently an option, you can outright delete the calendar and re-create it however, the downside to this is the change in the calendar id on re-creation.
Delete calendar documentation
Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.

Firebase Analytics Events - currentScreen is always screen_view

On my way implementing firebase analytics into my flutter app, i cant get the proper events to trigger or i dont get how this should work. Lets take the following code:
firebaseAnalytics.setCurrentScreen(screenName: "Dashboard");
When i trigger this event, in the Firebase Analytics debug view i see this:
The same when i trigger the screen changes automatically via:
navigatorObservers: [
FirebaseAnalyticsObserver(analytics: appState.firebaseAnalytics),
],
So my question is: Why does Analytics prints out "screen_view" instead of "Dashboard" or any other name i have in my named routes ??
The screen name is in fact submitted to the inner workings of the API cause i debugged firebase_analytics.dart on that place:
Future<void> setCurrentScreen(
{#required String screenName,
String screenClassOverride = 'Flutter'}) async {
if (screenName == null) {
throw ArgumentError.notNull('screenName');
}
await _channel.invokeMethod<void>('setCurrentScreen', <String, String>{
'screenName': screenName,
'screenClassOverride': screenClassOverride,
});
}
Answering my own question and thus wasting the bounty is hard but thats the way it is. Here are my findings:
The user provided screenName in the API gets submitted to the Firebase Analytics Dashboard but you need to drill down on the event "screen_view" to see the actual clicked screen Names you supplied. Unfortunately the user supplied Name wont be shown in the debugView of the Firebase Analytics console which got me on the wrong trail in the first place, thinking that its missing altogether, which is wrong.
tl;dr: screenName is just a parameter of screen_view Event and its right inside the screen_view event which you can drill down on.
Why route names don't show in the DebugView by using navigatorObservers? Looking for an explanation to this issue I got here and found the answer in Marc's Answer. It is actually being collected and is located as a parameter called firebase_screen.🧐

Restore missing or deleted calendar

Working with one of my Google Apps users and a shared calendar he create suddenly disappeared. It was hidden (first thing we checked), but just gone. It is a number of steps to delete a calendar (for safety reasons) and it was certainly not deleted in this fashion.
Using the Google APIs Explorer for Calendar API v3 we do see a deleted calendar using calendar.calendarList.list when showDeleted is true. If we highlight that item in the JSON response the dropdown arrow on the top right of the item shows it can be used in calendar.calendarList.patch. Trying to remove the "deleted" flag results in a 404 resource not found. Copied the calendarId from the Patch JSON body up to the calendarId box, fields editor to show most all fields. Trying the same for calendar.calendars.patch we get the same result.
The OAuth scope is https://www.googleapis.com/auth/calendar. JSON body is
{
"kind": "calendar#calendarListEntry",
"etag": "\"XXXXXXXXXXXXXXXX\"",
"id": "XXXXXXXXXXXXXXXXXXXXXXXX#group.calendar.google.com",
"defaultReminders": [
],
"deleted": false
}
If a calendar is deleted from the CalendarList but you still know the id, you can add it back to the list with the insert endpoint.

Using webhooks with Google Analytics

I'm trying to integrate my CRM with Google Analytics to monitor lead changes (from lead to sell) and so on. As I understood, I need to use Google Measurement Protocol, to receive webhooks from CRM and translate it to Analytics Conversions.
But in fact, I don't really understand how to do it. I need to make some script, to translate webhook code to analytics, but where I need to place that script? Are there some templates? And so on.
So, If you know some tutorials/courses/freelancers to help me with intergrating webhooks with Analytics - I need your advice.
Example of webhook from CRM:
{
"leads": {
"status": {
"id": "25399013",
"name": "Lead title",
"old_status_id": "7039101",
"status_id": "142",
"price": "0",
"responsible_user_id": "102525",
"last_modified": "1413554372",
"modified_user_id": "102525",
"created_user_id": "102525",
"date_create": "1413554349",
"account_id": "7039099",
"custom_fields": [
{
"id": "427183",
"name": "Checkbox custom field",
"values": ["1"]
},
{
"id": "427271",
"name": "Date custom field",
"values": ["1412380800"]
},
{
"id": "1069602",
"name": "Checkbox custom field",
"values": ["0"]
},
{
"id": "427661",
"name": "Text custom field",
"values": ["Валера"]
},
{
"id": "1075272",
"name": "Date custom field",
"values": ["1413331200"]
}
]
}
}
}
"Webhook" is a fancy way of saying that your CRM can call a web based service whenever something interesting happens (i.e. the CRM can "hook" into a web based application). E.g. if a new lead is created you can call an url with the lead details as parameters.
Specifics depend on your CRM, but when you set up a webhook there should be a field to set a url; the script that evaluates the CRM data is located at the URL.
You have that big JSON thing as your example - No real way to tell without knowing your system, but I assume that is sent as request body. So in your script you evaluate the request body, extract the parameters you want to send to analytics (be mindful that you are not allowed to store personally identifiable information) and sent it via the measurement protocol as described in the documentation linked in the other answer.
Depending on the system you might even be able to call the measurement protocol without having a custom script in between (after all the measurement protocol is an url with a few parameters).
This is an awfully generic answer, but then the question is really broad.
I've done just this in my line of work.
You need to first decide your data model on how you would like the CRM data to look within Google Analytics. This could be just mapping Google Analytics' event category, event label, event action to your data, or perhpas using custom dimensions and metrics.
Then to make it most useful, you would like to be able to link the CRM activity of a customer to their online activity. You can do this if they login online. In that case, you can set the cid and/or uid of the user to your CRM id.
Then, if you send in a GA hit with the same cid/uid in your Measurement Protocol hit, you will link the online sessions with your offline CRM activity.
To make the actual record hit Google Analytics, you will need to program something that takes the CRM data and turns it into a Measurement Protocol hit, which is essentially just a URL with the correct parameters. Look here for reference: https://developers.google.com/analytics/devguides/collection/protocol/v1/reference
An example could be: http://www.google-analytics.com/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA
We usually have this as a seperate process, that fires when the CRM data is written to its database (the webhook in your example). If its a lot of data, you should probably implement checks to see if the hit was sucessful, and caching in case the service is not online - you have an optional parameter that gives you 4 hours leeway in sending data.
Hope this gets you at least started.

How to tie together front and back end events in google analytics?

I am tracking user events on the front end with google analytics, but I would also like to send back end events and be able to match up events for the same user in google analytics.
It looks like I should be able to pass the uid parameter: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uid but it looks like I also have to pass the tid parameter https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid .
The docs say that "All collected data is associated by this ID" (the tid).
What should I pass for the tid? Why can't I just pass the uid, if that is supposed to be a mechanism for tying events together?
I would like the backend to pass the uid to the front end (actually a one-way hash of the email), and then refer to the user in google analytics with this uid.
Is this feasible? I'm a bit confused about how to implement this.
Many thanks!
The "tid" - Tracking ID - is the Web Property, i.e. the "slot" in your Analytics account that the data goes to. If you do not send a tracking id the calls will disappear in limbo. You find the tid in your property settings under "Tracking Code". It is a string that starts "UA-" and so is also sometimes referred to as UA-ID).
The User ID will not help you to identify users, at least not by default, since it is not exposed in the Analytics interface (it should really be called the "cross device identification id", since that is what it's for). You need to create a custom dimension and pass the value of the User ID there if you want to identify users. Per TOS you must take care that no third party, including Google, can resolve your User ID (or any other datapoint) into something that identifies a person, altough of course you can use yourself to connect data to other data in your backend system.
Actually there is a proper way. I've implemented this for myself.
There's a Client ID parameter, that should be passed with your requests.
And here's you have two options:
Create this client id manually (by generating UUID) on server-side and pass it to front-end. Then use this value when you create your tracker and also use it for server-side requests.
//creating of a tracker with manually generated client id
ga('create', 'UA-XXXXX-Y', {
'storage': 'none',
'clientId': '76c24efd-ec42-492a-92df-c62cfd4540a3'
});
Of course, you'll need to implement some logic of storing client id in cookie, for example.
You can use client id that is being generated automatically by ga and then send it to the server-side by your method of choice. I've implemented it through cookies:
// Creates a default tracker.
ga('create', 'UA-XXXXX-Y', auto);
// Gets the client ID of the default tracker and logs it.
ga(function(tracker) {
var clientId = tracker.get('clientId');
//setting the cookie with jQuery help
$.cookie("client-id", clientId , { path : "/" });
});
Then on the back-end just access this cookie and use that client id for your requests.
Also some information con be found here: What is the client ID when sending tracking data to google analytics via the measurement protocol?

Resources