2 Replies Latest reply on Feb 19, 2018 7:15 AM by stefanm38281801

    Best practices for Single-Page Apps

    worldholder

      What are the best practices for Single-Page Apps tracking using Launch? Basically, I'm looking for a robust techique for collecting / dispatching virtual pageviews (JS framework agnostic).

       

      Here https://marketing.adobe.com/resources/help/en_US/experience-cloud/launch/c_extension-dtm.h tml I found that Launch Core extension contains events like “Custom Event” and “Data Element Changed”.  I suppose I should use one of these features, but not sure which one to select as I don’t know their pros and cons. 

       

      On the web I found some examples for DTM only, I don’t know if they are applicable to Launch.

       

      When working with GTM, I used custom events for these purposes. However custom events in GTM are just key-value pairs pushed into the GTM data layer. But in the DTM-related articles which I saw on the web custom events refer to something absolutely different: Javascript-native interface called CustomEvent: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent

       

      Any suggestions / documentation on this?

      Thanks a lot!

        • 1. Re: Best practices for Single-Page Apps
          FOX007 Level 1

          For all our SPAs we use direct call rules which the developer would fire after the datalayer was ready. Custom events ion DTM I believe are page events such as button clicks, hash changes, etc. that trigger a rule to fire.

          • 2. Re: Best practices for Single-Page Apps
            stefanm38281801 Level 1

            We've build a framework for tracking, in which we use for DTM / Launch Custom Events. With Direct Call Rules, you can only reference a "static" Digital Data object, which might cause race conditions if you're not managing your Digital Data Object correctly.

            The advantage of Custom Events is that you can pass context data with the event; so we're passing the Digital Data Object as event data, and reference this directly from within DTM / Launch.

             

            This works flawless within traditional page based sites, as with SPA's. In an SPA, Dev would just "trigger" a "Page impression" event. In a traditional page based site, the "Page impression" is a trigger call on document.ready.