Dynamic web content is not loading for the first page load for an anonymous user

Got the same issue and never managed to fix this with the original mautic tracking code.

I think the problem is that the mtc tracking event needs to run first and set a cookie.

I remember there was a guy in this forum presenting a different loading technique for the dynamic content aftet the page event.

I‘m only on mobile right now. Looking for the thread later

Regarding the code loading issue:

You can try to hook into the mautic js code like this:

(function(global, document) {

    function load() {

        if(!window.MauticJS) return setTimeout(load, 250);
    
        //Register page tracking event in mautic 
        MauticJS.onFirstEventDelivery( function(){ 
            
            MauticJS.replaceDynamicContent();
            
        });
    
    }

    "complete" === document.readyState ? load() : document.addEventListener("DOMContentLoaded", load); 
    
}(window, document));

This should get init the dynamic content AFTER the mtc.js tracking event without changing the original trackinng code.

Thanks for this. Can you maybe explain a bit more and the implementation here, would this piece of code go into the html / Wordpress site and then where would I put the div calling the DWC ?

I tried something like this, however still not loading on first load:

<!DOCTYPE html>
<html>
<head>
    <!-- Other meta tags, styles, and scripts -->
    <script>
    (function(global, document) {

        function load() {

            if(!window.MauticJS) return setTimeout(load, 250);

            //Register page tracking event in mautic 
            MauticJS.onFirstEventDelivery( function(){ 

                MauticJS.replaceDynamicContent();

            });

        }

        "complete" === document.readyState ? load() : document.addEventListener("DOMContentLoaded", load); 

    }(window, document));
    </script>
</head>
<body>
    <!-- Your page content -->
  NEW
  <div data-slot="dwc" data-param-slot-name="contact-id-slot">
</body>
</html>

Hey Mikew

Sure:
The code expects that you include the mtc.js and that you track page hits.

My code hooks into an event that is thrown in mtc.js after the first page tracking and init the dynamic content.

Your demo html lacks the mtc.js script and does not do the normal page Hit tracking?

Is the a chance to see your problem live in a browser?

Greetings
Sebastian