Google API calendar fetch events calendar wise - google-calendar-api

Is it possible to fetch events from calendar, calendar wise?
As in not to fetch all the events altogether, fetch it calendar wise like the public and personal calendar separately and so on. I am using the Google API package. Is there any inbuilt function to do that? If not, then how should I implement it?
Provide the code in Php. Thanks.

The API endpoint you're looking for is Events: list. If you're using the API client library for PHP, there's an excellent, thorough example implementation to be found on the Google Calendars API PHP Quickstart.
That example demonstrates the steps involved:
Create a new Google_Client.
Use the client to create a new Google_Service_Calendar object.
Then $service->events->listEvents($calendarId) will return a collection of Event objects (see "Overview" in API ref).
$calendarId can be the ID of a calendar (find by using the API to get a calendarList) or the string primary to get the authenticated user's default calendar events.
listEvents() accepts an optional second parameter, an array of options that can limit the results by min date, max date, max attendees, etc.

Related

Google Tag Manager - dynamically send custom events with their params to Google analytics

I'm using Google Tag Manager (aka: GTM) to send events to my Google Analytics 4 account, some of them are custom that developers send thru the code like that:
dataLayer.push({
event: 'CA:some-event',
a: 1, // custom param
b: 2 // custom param
})
I defined a Trigger in GTM to catch all events that start with "CA:*" (as regex) and then i defined a new Tag: "Google Analytics: GA4 Event" to be invoked when the trigger fired and send the event to GA4.
I'm getting the events successfully to my GA4 account but the problem is that all params, a and b in my example, are not sent as they are not mapped to be sent from GTM layer within the GA event.
I can define Variables in GTM specifically for them but it's not dynamic and it means that every time a developer needs to send a new custom event he'll need to go to the GTM account (and usually they don't have access to it), add the variables and it makes the whole solution semi-automatic and not dynamic enough.
I hope it's clear.
Any suggestions here?
Unfortunately there is no easy way to manage GTM as the way you want.
Hope they can allow us to use just JavaScript object to send as event parameter. (They only allow Ecommerce DataLayer at this time)
But looks like your developer can decide the event parameter themselves. So the option here is if they don't have access to GTM. They can just tell the one who is handling the GTM that their new implementation. So the GTM guy can modify based on it.
If your scenario is the changing is a lot and it really need to be automatic. Then GTM API might be the way.
(But it also take some times for developer to integrate with it)
I used to manage more than 10+ properties and more than 30+ new events needs to add in a week.
So I choose Google Sheet(with Google App Script) to manage the GTM more easily.
The point here is there are still some ways to make it more automatic. Just need to leverage is it worth it do develop.
You can use the data layer variables in Google Tag Manager to dynamically send the custom parameters to Google Analytics 4.
Here's how you can set it up:
Create a Data Layer Variable in GTM to capture the custom parameters. To do this, go to Variables > New > Data Layer Variable. Name the variable and enter the parameter name in the Data Layer Variable Name field (e.g. "a" or "b").
Add the Data Layer Variables as fields in your Google Analytics 4 Event tag. To do this, go to your Google Analytics 4 Event tag and select "More Settings" > "Fields to Set". Enter the name of the Data Layer Variable you created in step 1 (e.g. "a" or "b") and the value {{a}} or {{b}} respectively in the value field.
Publish your changes in GTM.
Now, every time a custom event is pushed to the data layer, the associated custom parameters will be automatically sent to Google Analytics 4 as well. This allows you to dynamically send custom parameters without having to manually update the Google Analytics 4 Event tag each time a new custom event is added.
Note: Make sure that the custom parameters are consistent across all events, otherwise you may end up with mismatched data in Google Analytics 4.
If you feel worried about DataLayer then you can use JavaScript for scrapping Data. Anyways, Maybe It looks hard, If yes then you can connect to me for getting A-Z help. I'm GTM, GA4, and Conversion Tracking expert : Fb Profile
Thanks.
i ended with the following solution:
I changed the way I'm sending the event to be:
dataLayer.push({
event: 'CA:some-event',
data: {
a: 1, // custom param
b: 2 // custom param
}
})
set a variable in GTM called "Custom Event Data" based on the data property of the event
set the GA4 event tag to send it to GA4
set a new Custom Dimension in GA4 called "Custom Event Data" based on the data property
The limitation is that I cannot use a and b directly in GA4 as a native fields but at least I can see the variation of them in the GA4 reports

PageInfo in Firestore not usable

I would like to use pagination in Firestore so I can save a query state and automatically allow users to submit a page token to start a query again. The challenge I am seeing with this is that Firestore does not offer a query token or page token to resume iteration. However, after looking through the docs for GoLang, it looks like there is an exported PageInfo() method that returns a token I am interested in and an unexported fetch method.
Is there a method to use the exported PageInfo() values to allow me to fetch a new set of documents using that existing token?
To use pagination in Firestore Database you can use query cursors with limit() method as mentioned in this document. You can go through this youtube link to know more about it.
You may also consider using pageSize & pageToken query parameters and nextPageToken field with Firestore REST API as mentioned in this document to achieve pagination. There is a similar StackoverFlow thread which may help you.

Is there an API resource for the Reminders object existing in Google Calendars' GUI?

in google calendar you can create 3 different objects:
Event
Reminder
Task
I try to figure out which fields are provided by the google calendar for reminders.
I found the documentation for calendar events: https://developers.google.com/calendar/v3/reference/events
And I also found the documentation for calendar tasks (and task lists): https://developers.google.com/tasks/v1/reference/tasks
So I know which fields are provided and what there meaning is.
But unfortunately I am unable to find the documentation for the reminders and which fields they offer.
Does anyone know where/how to find the documentation for the reminders? Or which fields they provide in total? Or are they just events from a special kind?
IMPORTANT:
Unfortunately, at the moment there is no API resource for the new GUI reminder object. So ATM it can only be used through the GUI.
There is an issue created in the Public Issue Tracker for creating an API for reminders. Please use this link and add your two cents. Thank you !
You are on the correct documentation site for the reminders. You see, reminders are a property of the Event resource.
If you take a deeper look at the Event resource structure (scrolling down) you will find the property "reminders":
"reminders": {
"useDefault": boolean,
"overrides": [
{
"method": string,
"minutes": integer
}
]
},
Further down you have the Value, Description and Notes for each property ordered by Property Name.
Here is a screenshot of the reminders property details:
Here you have a bit more explanation about the concept of reminders in Google Calendar.
And this help page also has some useful.
But I believe the most important concept is that of the Default reminder which is reminder setting that applies to all events created in that Calendar.
Note:
The Calendar Event's reminder property is set to use the Default Reminder settings of the calendar to which it belongs by default. And can be overridden by specific settings for the event in question.

How do I create an Out of office type Calendar Event via the REST API?

Google Calendar has a new event type called "Out of office" that automatically will decline any events it is placed over and others that come in during the scheduled time of the event.
I inspected one of these event objects via the API and briefly checked the Google Calendar API documentation to see if there was a way to create these programmatically. I work on a system that schedules events on people's calendars when they are going to be out of the office as all day events to provide visibility to the rest of the staff. I would like to change these to be true Out of office event types if its possible via the API.
The short answer: It does not work currently (as of 08/2022)
The Google Calendar API currently exposes the eventType property as read-only. It will be discarded when sent in an insert payload.
eventType [string]: Specific type of the event. Read-only.
Possible values are:
"default" - A regular event or not further specified.
"outOfOffice" - An out-of-office event.
As mentioned by #ercliou in the comments, the ticket can be tracked here: issuetracker.google.com/issues/112063903
The only thing that seemingly marks an event as out of office is a private extended property on the event resource:
"extendedProperties": {
"private": {
"everyoneDeclinedDismissed": "-1"
}
}
Looking at https://developers.google.com/calendar/v3/reference/events/insert the attribute extendedProperties.private is writeable so you should be able to set it there.

Google Calendar JSON API - Get Multiple Calendar Feeds

In an iOS application, I'm using the Google Calendar API to retrieve some public calendar events in JSON format by making a GET request to this URL.
https://www.google.com/calendar/feeds/[feed_name]/public/full?alt=json
where [feed_name] is an ID identifying a specific public Google Calendar.
I have around 10 public Google calendars, whose events I need to display together in a list within my app. Currently, it seems like I'll have to make 10 GET requests and concatenate the results to achieve what I want.
Is there an alternative service endpoint to which I can provide a list of public Google Calendar IDs and I can get the concatenated list of events?
It seems to be possible to embed multiple public calendars together by adding multiple 'src' and 'color' parameters to the embed URL. But, how about getting multiple public calendars in JSON format through a web service?
Yahoo pipe :) seems to be the only one I found so far. I've been looking to this now for a few days and couldn't get other solutions :(

Resources