Skip to content

Dynamic Placements

Dynamic Placements is a feature that automatically creates div elements for ad placements on the fly. It’s particularly useful for scenarios like infinite scroll pages where you don’t know in advance how many ad slots you’ll need.

Dynamic Placements use XPath expressions to find elements on the page that match certain criteria. When a matching element is found, Htag creates a new div element after it. The system continuously monitors the page for new elements that match the configured XPath expressions.

Dynamic Placements continuously monitor the page for new matching elements. This monitoring happens at regular intervals, allowing Htag to respond to changes in the page structure.

You can pause this monitoring with stopDynamicPlacements. To resume it, use a page-transition refresh: either call refreshAds({ pageTransition: true }), or call refreshAds() for a new URL. A placement-only refresh with elementIds does not resume monitoring by itself.

Note that you still need to create placement definitions matching those dynamically created div elements.