Element presence trigger

Tag Manager

Available from 16.15.0

Video tutorial: watch on YouTube

An element presence trigger fires a tag when a specific element, like a button or form, is present on a page. It does this after the page has fully loaded (when the DOM is ready). Even if the element is added to the page after it initially loads, the trigger will still detect it and activate the tag.

By default, the tag fires whenever the selected element is present on any page. But you can change it so that the tag fires on a specific page or under specific conditions.

Element presence trigger in Piwik PRO

Here’s a list of conditions available in this trigger.

CSS selector conditions

Condition type Description Example
CSS selector Fires the tag when the selected element is present on a page. .promo_banner

Event conditions

Condition type Description Example
Page URL Fires the tag when a visitor is on a page with the selected page URL and the selected element is present. For example, a visitor is on the page https://clearbank.com/product-tour and the selected element is present. Page Url equals https://clearbank.com/product-tour/
Page path Fires the tag when a visitor is on a page with the selected page path. For example, a visitor is on the page that contains the path /product-tour and the selected element is present. Page Path contains /product-tour
Page hostname Fires the tag when a visitor is on a page hosted on the selected domain and the selected element is present. For example, a visitor is on the page that is hosted on clearbank.com and the selected element is present. Page Hostname equals clearbank.com
History source

Fires the tag when a visitor is on a page where a specific history event (pushState, replaceState, popState or hashchange) occurs and the selected element is present.

For more on the history object, see this article.

History source equals pushState
History fragment Fires the tag when a visitor is on a page where the hash in the page URL matches the selected condition and the selected element is present.

History fragment equals pricing

Example URL: https://example.com/#pricing

Old history fragment

Fires the tag when a visitor is on a page where the previous hash in the page URL matches the selected condition and the selected element is present.

For more on the hashchange event, see this article.

Old history fragment equals about-us

Example previous URL: https://example.com/#about-us

History state

Fires the tag when a visitor is on a page where the history state in the page URL matches the selected condition and the selected element is present.

For more on the history.state property, see this article.

History state is set

or

History state equals my-state

Old history state

Fires the tag when a visitor is on a page where the previous history state in the page URL matches the selected condition and the selected element is present.

For more on the history.state property, see this article.

Old history state is set

or

Old history state equals my-state

Referrer Fires the tag when a visitor is on a page to which they were directed by the selected referrer and the selected element is present. This referrer is internal, meaning that it belongs to the same domain as your site. For example, a visitor comes from https://clearbank.com/blog and the selected element is present. Referrer equals https://clearbank.com/blog
External referrer Fires the tag when a visitor is on a page to which they were directed by the selected external referrer. This referrer is external, meaning that it has a different domain than your site. For example, a visitor comes from https://google.com and the selected element is present. External referrer equals https://google.com
Campaign Fires the tag when a visitor is on a page to which they were directed by the selected campaign (based on the utm_campaign parameter) and the selected element is present. Campaign equals winter-promo
Traffic source

Fires the tag when a visitor is on a page to which they were directed by the selected traffic source and the selected element is present.

Possible values: campaign, organic search, social, referral, direct.

Traffic source equals direct
Returning visitor Fires the tag when a visitor is a returning visitor and the selected element is present. The returning visitor is recognized by Tag Manager, which uses the stg_returning_visitor cookie. Returning visitor is true
Variable-based conditions Any variable you add will appear in the list of conditions and you can use it to define trigger conditions. ––

Tip: Learn more about trigger conditions.

Multiplicity

Possible multiplicity conditions
Each time new elements are found
Once for each page view
Once in a session

Was this article helpful?

Technical support

If you still have any questions, visit our community.
There’s always someone happy to help!

Back to help center