10-23-2025 01:32 PM - edited 10-23-2025 01:37 PM
By default, the Invoca tag automatically functions upon the initial page load. However, many modern websites load content and components dynamically after the initial page load (e.g., via AJAX, single-page application transitions).
To ensure Invoca can correctly identify and replace phone numbers within these dynamically loaded elements, you must manually trigger a re-scan of the page using the Invoca.PNAPI.run() function.
It can be achieved by using Google Tag Manager (GTM) and an Element Visibility Trigger. This setup ensures the re-scan runs precisely when the new, number-containing element becomes visible.
Set up a GTM trigger that detects when the new, dynamically loaded element appears on the screen.
Create a Custom HTML Tag that contains the JavaScript code to initiate the Invoca re-scan, and link it to the trigger created in Step 1.
<script>
// Check if the Invoca object exists before attempting the run command
if (window.Invoca) {
Invoca.PNAPI.run();
}
</script>
This setup ensures that whenever the target element becomes visible, the Invoca tag re-scans the page, allowing it to successfully target and replace any phone numbers within that new content.