Creating a rule only for the front page

The challenge with the basic “Visitor’s url contains” rules condition is that it does not look at what comes before or after the given string. If we have a rule with simply “Visitor’s url contains:”, the condition will be met on all pages on as all pages contain “”.

If we want to target visitors only on the front page we can do so by using the “Visitor’s url (regexp)” condition. This allows us to do different tricks with URLs by using javascript regular expressions. The url for the front page is added to the condition and a $ is added at the end of it. This way we are checking that the visitor’s url is exactly the given URL and there are no characters after it.

As an example, we want our rule to trigger for visitors on the front page
Our rule condition would therefore be: When Visitor’s url (regexp) matches:$

Screenshot 2021-05-25 at 15.19.19