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.
Any suggestions / documentation on this?
Thanks a lot!
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.
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.