combine multiple google tag manager triggers - google-tag-manager

I'm trying to achieve the following:
One GTM container for multiple websites/domains (within the same platform)
Only fire tags that are active for the current website (by checking configured analytics / criteo / adwords / other vendor account id in data layer)
Configure triggers like 'booking page reached' and 'booking created' once (by custom event and using data layer)
My problem is combining the condition 'active tag' (checking for account id) with a 'booking created' event without duplicating logic.
Because every trigger is an OR condition, not an AND condition.
Currently, this results in creating exceptions that are very specific, and contain most of the triggers like 'Booking created', specific for a tag (Analytics / Criteo / Adwords).
Resulting in having to still make very specific (duplicate) triggers, instead of re-using them.
Main issue is exceptions have to match the event type of the trigger. And triggers cannot be combined nor extended.
My tags / triggers configuration looks like this now:
My questions:
Is there a way to combine multiple triggers (AND instead of OR)
Can I create an exception for tag that is not depended on the same event as the original trigger?
Am I looking for a solution in the wrong direction? How do I prevent triggering a tag that is disabled (by dataLayer), without duplicating 'custom events' logic for every different tag / vendor.

If your main problem is that "exceptions have to match the event type of the trigger", the common workaround is to use a trigger of the type "custom event", check "use regex" and enter ".*" (without the quotes), which matches all events, including the built-in pageview (gtm.js), DOM ready (gtm.dom) and Window loaded (gtm.load). Then add conditions as needed.

There is a more powerful and easiest way to combine triggers in multiple AND and OR.
First of all: if you need to combine triggers with just OR condition, you can simply add a list of triggers when you are configuring a tag.
I am no talking about exceptions, just triggers. You can click on the (+) symbol and every trigger you add is managed with OR condition.
But, if you need, for instance, to add two triggers in AND? There is a very simple way that does not imply the regex.
Is the trigger group feature.
Here are the steps.
Create all the triggers you need to compose (in this phase you don't need to combine them, just one trigger at a time)
Then create a new trigger, but in this case, choose the last type in the list, that is "trigger group". Et voilà... you can combine in the group any of the existing triggers and define if you wnat combine them with AND or OR!!!! :)
Finally, go to your tag and use the GROUP instead of the single trigger.
That's all

Related

Google Calendar API V3: Identifying edited one-offs of recurring events?

I am currently listing all events from a Google Calendar using the "singleEvents" parameter set to true, which splits recurring events into individual events – which is good. However, I'm running into an issue when an instance of a recurring event is edited, and the edits are saved with the "Only this event" option in the Calendar UI.
What I need to do is be able to identify which of these recurring event instances have been edited, and which have not. It seems the API response data does not provide any indications of whether this is an instance of the unedited recurring event, or an edited one-off. The response for an unedited instance of a recurring event and an edited instance are more-or-less the same, save the description field, which was edited.
The reason I need to differentiate edited versus unedited recurring event instances is that I am dynamically creating event detail pages from the list of single events. I would like to have one page be for the recurring event itself, and another for a "one-off" of that recurring event. E.g:
allmyevents.com/events/my-recurring-event --> page showing recurring event with recurrence information
allmyevents.com/events/my-recurring-event/16-4-2020 --> page showing specific instance of recurring event, which has been edited
Currently, I'm able to do this by creating an entirely new event at the same date and with the same title as the recurring event instance I want to replace, and writing hacky comparison logic to tell if this is a replacement event, but this is counter-intuitive for event/content management.
Answer:
You can use the Calendar API Events: instances endpoint to return all instances of a recurring event. All the events which have been edited on their own will not be returned.
More Information:
The Events: instances endpoint of the Calendar API will return all instances of a recurring event for a calendarId and eventId specified. Any of these that have been edited are omitted.
It's a bit of a workaround, as these events can't be obtained directly, but by obtaining the list of events as you have already been doing and then removing the events which are returned by Events: instances, you can build a list of all the events which have been edited with the 'Only this event' option.
Psuedo-code:
You can do something like this:
eventsList = Calendar.Events.List(calendarId, singleEvents=true)
eventsInstances = Calendar.Events.Instances(calendarId, recurringEventId)
singleEvents = eventsList
for each instance in eventsInstances :
if eventsList.items contains instance :
singleEvents.remove(instance)
return singleEvents
Where the returned singleEvents variable will be a list of all the events that have been edited manually.
References:
Events: instances | Calendar API | Google Developers
Recurring Events | Calendar API | Google Developers
I've been puzzling through this same issue, and I think I've found a way forward that doesn't involve going through every single instance to check if they've been moved/edited:
Each event returned by the Calendar API has an iCalUID field. For a standalone event, this should match the event's id, with an #google.com suffix. e.g. an event with the id of abcdef has an iCalUID of abcdef#google.com.
When it comes to recurring series, every single instance of that event has the same iCalUID value - and, most importantly, you can use iCalUID as a filter when listing events, which will return the main recurring series event and all modified instances. Unmodified instances are not returned.
Tracking which instances have been deleted is slightly more fiddly. They might be returned in the list with the matching iCalUID, but with a status set to cancelled. Or, they may be specified within the recurrence property (an array of strings) on the main series event as timestamps (within the given time-zone, which should match whichever time-zone the main series event uses):
[
"RRULE:FREQ=WEEKLY,COUNT=5",
"EXDATE;TZID=Australia/Melbourne:20211227T110000,20220103T110000"
]
I haven't figured out why some recurring events use the specific-instances-as-cancelled approach, and others use the EXDATE approach (and I think they can also be combined, so don't presume the presence of one rules out the other). Given both are possible, you'll have to allow for that.

Doctrine innerOrder[int] column implementation for manual sort order control

I have two tables in my app's schema: Event and Game (one-to-many). Games are ordered by datetime field. But sometimes there can be games played in parallel (same datetime), but the user should be able to set their relative order.
I've added innerOrder (int) field with simple idea: it should have autogenerated value that can be changed on reorder (exchange with neighbor record). But I can't achieve this behavior with Doctrine: GeneratedValue can't be used twice / with separate field (just don't work this way).
On the next attempt I've tried to do it without autogeneration. But I need some initial value on insert, for example: MAX(innerOrder) (better - to set it automatically of course).
I can't do it in prePersist or similar methods - don't have access to repository class. And don't want to do it with additional query in controller - not only because of additional code I should insert each time (get max value from table, set inner order), but I'm afraid of possible conflicts (when two users are adding Games in parallel).
How should I achieve expected behavior (maybe, I'm totally wrong here)?
There is no need in achieving this behavior with Doctrine, you can manage this value from aggregate root. I.e when you attach the Game to the Event you can update it innerOrder value according to maximum of currently attached games + 1. Conflicts could be easily avoided with different kind of locks on Event you edit (i.e fetcing it with doctrine write lock or some kind of shared locks or mutex (see symfony/lock))
After it you can specify your relation confiration to fetch it with given order using this documentation
https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/ordered-associations.html
My two cents: when creating/modifying an event, you can check if there's one already at the same time (default innerOrder is 0, or even count(*) of the events at the same time). You can issue a warning when there's another event, ask for the order, or take to a form where you can manually reassign the order of the events.

How to completely delete recurring event instance?

If you create a recurring event in google calendar, you actually create one single event (parent) with recurrence rule, others are just virtually added. Once you move any of those virtuals, it gets saved as instance and you can edit it in any way you like without affecting the parent event itself.
If you edit that instance to match its parent, it gets deleted and replaced with the virtual one once again. (No need to keep instance which is no different from the parent event, right?)
I'm doing the same in my application. However, when I'm trying to do so using google-php-api-client, the only option to delete something, is to set the event status as 'cancelled' which will make the instance deleted.
My question is:
How to delete (or reset) the instances without the need of updating them one by one to match its parent?
EDIT: Forgot to mention why do I need this and what am I trying to achieve.
Basically, if you edit an instance, Google will ask you whether you want to edit "Only this", "Following", or "All" of the recurring events. If you select "Following", google will throw away everything related to the parent event from this date (where original_start > date), modify its rule to set UNTIL rule with the date of instance being edited and pass its old rule to newly created event with starting time same as the date of this particular instance.
Since I know of no method, how to delete multiple events matching some condition. The only way I could figure this out, is to select all of those, and update them one by one, which could be a bit of problem since you can:
Create recurring event with recurrence-end unspecified
Decide to modify all following events

Once event was reported to Universal Analytics - is there any way to remove or modify it?

Suppose an event was reported to Google Analytics using their API. Once reported, is there any way to remove or modify the event?
Generally speaking, there's no way to delete or modify historical data - once it's in there, it stays there. However, you can try to use filters to filter the data you want "removed". For example, to exclude an event, you can create an Exclude filter to filter your event by category, action, or label.

Drupal - Rules Condition that node has been updated more than once?

Is it possible to have a Rules Condition that a node has been updated more than once?
I need different email alerts for when content is created and when its updated. The issue is that im using the Multistep module:
http://drupal.org/project/multistep
The Multistep module breaks the node creation form into 2 or more separate pages. One the first page the node is created but unpublished. When you finish all the steps the node is updated and published. I need the email to be sent after the node has had all the steps filled in, as the CCK fields are used in the email. Therefore I cant use Rules inbuilt event of 'After saving new content' and 'After updating existing content'.
How can I differentiate in Rules from when the node is first fully filled in, and when its subsequently updated? One way to do this would be to have different conditions for weather the node has been updated once or more than once. Is this possible and if so, is it the best solution?
Thanks
I think the easiest way to do this would be too look at the URL or referrer like mentioned here, http://drupal.org/node/827728. You'd have to use the Execute PHP functionality and have some knowledge of how to write a short script though.
PROBLEM:
How to test for the number of times a node has been modified.
POSSIBLE SOLUTION:
Include a "counter" field in the CCK that is hidden from the user (via CSS) and auto-incremented each time the node is accessed. Then use the value of this counter in rules conditions.
(See e.g., http://drupal.org/node/1172550 for more details)
PROBLEM:
How to treat a node differently based on whether it is being 'added' for the first time, or 'updated'.
POSSIBLE SOLUTION:
Create a path rule that is conditional on node type.
Trigger the path rule for the node/add page of the specific node type.
Pre-populate fields on the node/add page using the elementdefaults module.

Resources