How to mute an alert during the night?
In cases where you need to be alerted when key actions, such as form submissions or transactions, are null especially during specific low-traffic periods like nighttime, you can set up alerts as shown below. The aim is to quickly detect interruptions in essential activities to optimise conversion efficiency on your websites.
Let's take the following case:
We have a goal called 'Callback request', which corresponds to the number of visits where users clicked the button on our website to be contacted back. We would like to set up an hourly alert when this goal hits 0, but we want to mute this alert during the night (from 10 PM to 7 AM).
Intuitively, it seems reasonable to think that creating the following segment:
And applying it directly to our alert would allow us to receive alerts during the desired period. However, in practice, by observing the alert preview, these are all the times of day when we actually receive them:

At first glance, one might think that this segment only counts visits that reach the 'callback Request' goal between 10 PM and 7 AM. Logically, we would expect to receive an alert only if this goal is not achieved during the night (thanks to the 'lower limit' set to 0).
However, this is not what happens in reality.
When applying this segment to an alert in Piano Analytics, the system tries to apply this filter to each hour of the day. If it doesn't find any visits matching the segment criteria during a given hour, it interprets this as a null value.
This behaviour becomes problematic when the goal is naturally absent during certain time slots outside of 10 PM–7 AM: the alert still applies the segment and, finding nothing, returns zero. Because our alert is set to trigger when the value is null (lower limit = 0), we end up receiving alerts all day long.
To work around this behaviour, here is the method to follow:
Creation of the 'Callback Request' segment:

This segment allows you to see visits that have triggered the 'Callback Request' goal at least once.
Creation of the 'Include Day' and 'Include Night' segments:
Include Day:
A1: Targets hours between 7 AM and 10 PM

Include Night:
A1: Targets hours after 10 PM.
A2: Targets hours before 7 AM.
Use the 'OR' operator to combine A1 and A2, including all visits outside of 7 AM to 10 PM.

Creation of Custom Metrics :
'One' Metric:
You will need to create a metric that is always equal to 1, which will later allow us to never have a value considered as null outside of our segment.

Creation of the 'goal_type_filtered' metric for which we want to be alerted:

This will account for visits between 7 AM and 10 PM that have not fulfilled the 'Callback Request' objective, as well as those coming in after 10 PM and before 7 AM, which are initially considered to have a conversion rate of 0 (because they did not meet the criteria of our segment as explained above). By using the custom metric 'one', which we have segmented above (with the 'include night' segment), we ensure that all conversions outside the 7 AM - 10 PM period are equal to 1 instead of 0, contrary to normal behaviour.
Alert Configuration:
By setting up our alert as follows, namely by including the 'Callback Request' segment and applying the limit only lower than 1:

When we display the preview of this alert using the 'Alert Preview' option, we can see that this alert is triggered at the correct time.
