Java Google Calendar API: Send email notification when creating event - google-calendar-api

I am using java google calendar API. Whenever I create a new event I would like to send an email notification to all attendees.
I guess/expect there are 2 ways how to achieve that:
Set it as the calendar property
Set it ad hoc as property on the created event
I don't care which of these options I use but I don't know how to do it programmatically and I am struggling to find any example of the code.

As you can read in the documentation, about the sendUpdates parameter:
Whether to send notifications about the creation of the new event.
Note that some emails might still be sent. The default is false.
Acceptable values are:
"all": Notifications are sent to all guests.
"externalOnly": Notifications are sent to non-Google Calendar guests
only.
"none": No notifications are sent. This value should only be
used for migration use cases (note that in most migration cases the
import method should be used).
You can follow the insert Example besides the Quickstart to set the previous configuration, but take into account that there is an outdated dependency that makes you use the deprecated sendNotifications instead of sendUpdates:
compile 'com.google.apis:google-api-services-calendar:v3-rev305-1.23.0'
should be
compile 'com.google.apis:google-api-services-calendar:v3-rev401-1.25.0'
I already reported the issue to Google.
Assuming that you already have the object created event, with the list of attendees, the API call should be:
service.events().insert(calendarId, event).setSendUpdates("all").execute();

Related

Tracking Google Tag Manager publish events

How would I detect a Google Tag Manager publish event and send that to an external system?
I am trying to pinpoint effects of specific tag changes for certain properties and correlate them in a graph the way I might do with a new GitHub tag being created.
I've looked thru documentation but have not uncovered anything yet specifically for this scenario.
You could user container notifications to have an email sent to some service that processes the mail and stores the information.
Or you can use the API, retrieve the container fingerprint and compare it against a stored version of the fingerprint to see if it has changed. This would require you do implement some sort of polling in the API script to check every n minutes for changes.

Google Analytics 4 - Measurement Protocol API used without gtag.js or firebase

Is it possible to use GA4 Measurement Protocol to send events to Google Analytics and view and analyze them in the GA dashboard without using gtag.js or any other front-end script? The use case would be that some events are being sent to my server and I will just push these events to GA through the API.
One thing that makes me think is that the official Measurement Protocol API say:
In order for an event to be valid, it must have a client_id that has already been used to send an event from gtag.js. You will need to capture this ID client-side and include it in your call to the measurement protocol. In send an event to your property, we use "client_id" as the client_id. You will need to replace this with a real client_id that comes from gtag.js.
(https://developers.google.com/analytics/devguides/collection/protocol/ga4/verify-implementation?client_type=gtag)
That suggests that only events that have a valid client_id that originate from gtag.js will be counted.
I did some experimenting with randomly generated client_ids and what I discovered was that I was able to see my events in the Realtime section of the GA4 console (the Event count by Event name section), but all the other sections would be empty and the Users in last 30 min section would always show 0.
Can someone please explain to me why it's zero and if such a use case is valid at all? Thanks
tl;dr
You can use any value in client_id, as long as it uniquely identifies the user (we use a GUID/UUID), but it seems like you also need to send a value in user_id. We use the same value for both.
Also, you need to add the 'engagement_time_msec' parameter to get any user metrics to register.
Longer answer:
We're trying to do the same, i.e. send all events to the GA4 Measurement Protocol from the server, so that it is not dependent on the current user's GDPR cookie settings.
We currently do this for a Universal Analytics property with no issues, but it seems that Google is trying to prevent this in future, by restricting the scope of the Measurement Protocol in GA4, whilst forcing everyone to move to it by July 1st 2023. See the documentation at https://developers.google.com/analytics/devguides/collection/protocol/ga4#full_server-to-server, where it states:
While it is possible to send events to Google Analytics solely with
measurement protocol, only partial reporting may be available. The
purpose of measurement protocol is to augment existing events
collected via gtag, GTM, or Firebase.
We have something working with GA4, in that the events are being registered on the GA4 property correctly, using a client id that is just a GUID/UUID that we define in our own site cookies. So, any value can be used in the client id, as long as it uniquely identifies the user. The same value is used to populate the user_id parameter.
When sending events, the realtime event details were showing on the GA4 dashboard, but user metrics were not until we also populated the 'engagement_time_msec' parameter, as described in https://stackoverflow.com/a/71482548/7205473
We still have issues with things like getting the user location and the platform details, which previously were automatically populated by passing the IP address and the User Agent, but which seem to no longer work in GA4.
We were also passing page load timing events through the Measurement Protocol, but again, these features seem to have been removed in GA4.
It is possible to use GA4 directly without gtag.ja or the Firebase SDK. Its not supported, so it takes some work. We have this working in a desktop app reasonably well. There a couple things that need to be done.
As stated elsewhere the "engagement_time_msec" param must be set using the "_et" parameter. This is the number of milliseconds between now and the previous event.
The client id "cid" has a specific format; it should be:
"randomNumbers(10).unixTimeStamp()"
The session id "sid" format is:
"randomNumbers(10)"
The "_z" parameter needs to be set. I think this is a cache buster. Looking deep into the gtag.js code it is a url safe base64 encoding of "CCD", which always results in the value "ccd.v9b"
The page hash parameter "_p" can be set to this; not totally sure its correct but it works.
"randomString(3).randomString(3)"
Set the "User-Agent" HTTP request header in whatever framework/lib you are using. GA4 uses this to determine many things including Operating System. You will need to create a fake user agent based on the local device information. This is what we use for a Windows 11 x64:
"myco.testapp/4.0.0 (Windows NT 10.0; Win64; x64)"
The IP will be taken fromn the web request which is where the geolocation data comes from.
Since a full working example is worth 1,000 words of documentation; here is a "test" event with a parameter "animal=dog":
https://www.google-analytics.com/g/collect?cid=0078745494.1659679529&_et=364&_p=pfJ.Aev&seg=1&sid=2678664821&tid=G-???&ul=en&v=2&_z=ccd.v9b&en=test&ep.animal=dog
It's possible to extract outgoing GA4 request from a GTM container debug/preview view and map any GA4 (automatically collected and custom) event.
Example page_view request URL:
https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXXXXXXX&gtm=3oes1i1&_p=1545013558&_dbg=1&cid=P%2FdJWyULMwcT21TMrzn7pZdlNt%2FxtttGVqGUmqNYbhc%3D.1669722847&ul=nl-nl&sr=2560x1440&uaa=x86&uab=64&uafvl=Not_A%2520Brand%3B99.0.0.0%7CGoogle%2520Chrome%3B109.0.5414.75%7CChromium%3B109.0.5414.75&uamb=0&uam=&uap=Windows&uapv=10.0.0&uaw=0&_s=1&_uip=XXX.XXX.XXX.X&sid=1674235261&sct=1&dl=https%3A%2F%2FXXXXXXXXXX.com%2F%3Fgtm_debug%3D1674235654105&dr=https%3A%2F%2Ftagassistant.google.com%2F&dt=OM%20test&jscid=XXXXXXXXXX.1669722847&seg=1&en=page_view
Tip: use Postman to analyse and experiment with parameters
regardless of the platform used to make a call the Measurement Protocol, you should use a client id generated by gtag.js, or the app ID if using Firebase.

Google Calendar Push Notifications: New events and event validation before/after creation

I would like to now if the following functionality is supported by google calendar api:
Does the functionality provided by "Push notifications" include new events or just existing ones. Here is a copy paste from the documentation that let me doubt that new event notifications are supported "The Google Calendar API provides push notifications that let you watch for changes to resources.". So does this only apply to already existing resources (events on my case).
Is there a way to limit the availability on the google calendar. By this I mean setting a general limit (i.e working hours for a company for example from 9am to 5pm). And putting the logic further, is there a way to add more constraints. For example after I receive a notification of a new event created (if this functionality is provided), I check the event's data in my web-hook and let google calendar know that this event shouldn't be considered as valid.
If these requirements are not provided already by google calendar API, I am open to any suggestions to accomplish this even if it takes more coding.
Just to make it clear. The context of these questions is when the user creates an event in their google calendar through google calendar web interface not through my application.

Incoming call notification for RingCentral

I am developing a C# application to notify user in real time for the incoming call. I am able to get SMS notifications successfully but not able to get notifications for the calls.
I am using RingCentral C# Github to develop.
Thanks in advance.
If you can get SMS notifications and want call notifications, you just need to modify your event filters and subscribe for presence events. A list of events is available in the API Reference. I've added a few deep links to call events below.
API Reference: https://developer.ringcentral.com/api-docs/
Account Presence Event
/restapi/v1.0/account/{accountId}/presence
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetAccountPresenceEvent
Extension Presence Events
/restapi/v1.0/account/{accountId}/extension/{extensionId}/presence
/restapi/v1.0/account/{accountId}/extension/{extensionId}/presence/line/presence
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetExtensionPresenceEvent
Detailed Extension Presence Events
/restapi/v1.0/account/{accountId}/extension/{extensionId}/presence?detailedTelephonyState=true
/restapi/v1.0/account/{accountId}/extension/{extensionId}/presence/line/presence?detailedTelephonyState=true
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetDetailedExtensionPresenceEvent
Extension Presence Line Event
/restapi/v1.0/account/{accountId}/extension/{extensionId}/presence/line
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefGetExtensionPresenceLineEvent
Missed Calls Event
/restapi/v1.0/account/{accountId}/extension/{extensionId}/missed-calls
https://developer.ringcentral.com/api-docs/latest/index.html#!#MissedCallsEvent

Firebase+GTM SDK - accessing GA tracker Client ID

I am implementing v5 Firebase+GTM SDK with the sole purpose of tracking the events in Google Analytics.
I can't seem to find a way to access GA Client ID (using previous versions of GTM SDK, I was able to access tracker object and get or set the value).
I am talking about this value:
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid
Is there a way to reach to GA object hidden inside FIRAnalytics?
Yeah, I don't think tracker object is surfaced.
What you can do is to generate your own clientID (a simple guid would do) and in Google Tag Manager configure a tag to set it as a field. This way you will fully control the cliend id (&cid) and therefore change it as you see fit
This is not possible as of today, since Firebase does not expose data via a REST API. There is no API to even pass on the GA client ID.
From GTM's side of things, that is again a closed system since the data from Firebase is intercepted by GTM but cannot be pulled out or tweaked before it is passed to GA.

Resources