Expand my Community achievements bar.

SOLVED

DTM: Fire Adobe Analytics on DOMReady

Avatar

Level 3

Hi,

for a DTM implementation on a jive system we need to fire Adobe Analytics tracking call until DOMReady is reached.

We want to collect attributes and data from jive which seemed to be set asynchonous in DOM. At the moment Analytics it is fired most of tracking information is yet not set in DOM.

Any idea how to tell DTM to execute Analytics tracking call when the jive object is ready?

Thanks & Regards,

Michael

1 Accepted Solution

Avatar

Correct answer by
Level 1

Hi all,

We resolved this by adding a custom code which returns false in the "Customize Page Code" panel of the tool  and/or Page Load Rules .

In our case, we don't use Page Load Rules but only Direct Call Rules for all pages : to be able to track pageView on assynchronous loaded content while ensuring all needed data are set even if they are set after the last available Page Load event (domready), we prevent the default pageView tracking by returning false in the "Customize Page Code" panel of Analytics tool, and this after having launched an iterative checking of the requested data wich will then trigger the according Direct Call Rule, like so :

var appVersion = _satellite.getDataElement('AppVersion'), //doWhenReady is a custom fn which execute the toCheck fn every 100 ms for a maximum of 10 times : //toCheck checks that the desired Data Element (dataToCheck) are set and not empty //the todo function is executed as soon as toCheck returns true or at the end of the iteration //(a "DataElementName_missing" value would at least be showing up in my reports so that I can instigate //why this Data Element would still be missing  more than 1 second after _satellite script was loaded) doWhenReady = doWhenReady || _satellite.getDataElement('HELPERS doWhenReady'), eventId, dataToCheck = ['UserLoginStatus'], fn = function () {return true;}, tocheck = function (fn) { var i = 0, isOk = true; fn = fn || function () {return true;}; for (i = 0; i < dataToCheck.length; i++) { //Here Data Elements are custom scripts which may return differents empty values var dta = _satellite.getDataElement(dataToCheck[i]); if (dta === '' || dta === {} || dta === dataToCheck[i] + '_missing' || typeof dta === 'undefined' || dta === 'undefined' ) { isOk = false; break; } } return (isOk && fn()) }, todo = function () { _satellite.track(eventId); }; //switch statements for defining which Direct Call Rule to trigger depending on the context, //default to the "pageViewDefault" direct Call rule if (appVersion === 'theVersionToTrack') { switch (_satellite.getDataElement('PageSection')) { case 'products' : case 'shop' : dataToCheck.push('ProductId'); eventId = 'pageViewProductView'; break; case 'register' : switch (_satellite.getDataElement('PageName')) { case 'welcome-to-our-club' : case 'welcome-offer' : eventId = 'pageViewRegistrationComplete'; dataToCheck.push('UserClubMemberId'); break; case 'personal-information' : eventId = 'pageViewRegistrationStart'; break; default: eventId = 'pageViewDefault'; break; } break; case 'checkout': dataToCheck.push('UserClubMemberId'); dataToCheck.push('Cart'); switch (_satellite.getDataElement('PageName')) { case 'shopping-bag': eventId = 'pageViewCheckoutshoppingBag'; break; case 'delivery-setup' : eventId = 'pageViewCheckoutDeliverySetup'; break; case 'order-confirmation' : eventId = 'pageViewCheckoutConfirmation'; dataToCheck.push('OrderId'); break; default : eventId = 'pageViewDefault'; break; } break; //if none of the above condition is met, then do a s.t() through the //default 'pageViewDefault' Direct Call Rule default: eventId = 'pageViewDefault'; break; }; doWhenReady('Check data for ' + eventId, todo, tocheck); } // Returning false here prevents _satellite from executing s.t() by default on any Page Load Rule : //if this code is set to take precedence over UI settings, this means you must have at least one //default Direct Call Rule which does it for all other pages of your website return false;

View solution in original post

10 Replies

Avatar

Employee

Michael,

You can use a direct call rule to control the timing of the load order of specific events like this.

_satellite.track(ruleConditionValue);

For more information on Direct Call rules see this section in the help docs. https://marketing.adobe.com/resources/help/en_US/dtm/rules.html

Avatar

Level 2

Michael,

Have you resolved this? I have a similar issue and was hoping to find resolution.

Thanks,
Chad

Avatar

Level 3

Hi Rudi et al ...

 

Thanks for the answer, but I want to control the point of the Adobe Analytics Call at all.

Problem:

At the moment we get basic page information like user id (=visitorID), community topic, thread Name (=pageName) etc .asyncronous by Jive, and we want to include this in one Adobe Analytics page load call.

At your approach I get a call of Adobe Analytics (page bottom) with empty pageName and a second from Direct Call rule.

I would like to prevent Adobe Analytics from doing its standard bottom page tracking call and doing the s.t() diretly from the Direct Call Rule. Is tha possible?

Avatar

Level 2

Michael,

Did you get an offline answer here? I got the same answer, but the same result as you.

Chad

Avatar

Correct answer by
Level 1

Hi all,

We resolved this by adding a custom code which returns false in the "Customize Page Code" panel of the tool  and/or Page Load Rules .

In our case, we don't use Page Load Rules but only Direct Call Rules for all pages : to be able to track pageView on assynchronous loaded content while ensuring all needed data are set even if they are set after the last available Page Load event (domready), we prevent the default pageView tracking by returning false in the "Customize Page Code" panel of Analytics tool, and this after having launched an iterative checking of the requested data wich will then trigger the according Direct Call Rule, like so :

var appVersion = _satellite.getDataElement('AppVersion'), //doWhenReady is a custom fn which execute the toCheck fn every 100 ms for a maximum of 10 times : //toCheck checks that the desired Data Element (dataToCheck) are set and not empty //the todo function is executed as soon as toCheck returns true or at the end of the iteration //(a "DataElementName_missing" value would at least be showing up in my reports so that I can instigate //why this Data Element would still be missing  more than 1 second after _satellite script was loaded) doWhenReady = doWhenReady || _satellite.getDataElement('HELPERS doWhenReady'), eventId, dataToCheck = ['UserLoginStatus'], fn = function () {return true;}, tocheck = function (fn) { var i = 0, isOk = true; fn = fn || function () {return true;}; for (i = 0; i < dataToCheck.length; i++) { //Here Data Elements are custom scripts which may return differents empty values var dta = _satellite.getDataElement(dataToCheck[i]); if (dta === '' || dta === {} || dta === dataToCheck[i] + '_missing' || typeof dta === 'undefined' || dta === 'undefined' ) { isOk = false; break; } } return (isOk && fn()) }, todo = function () { _satellite.track(eventId); }; //switch statements for defining which Direct Call Rule to trigger depending on the context, //default to the "pageViewDefault" direct Call rule if (appVersion === 'theVersionToTrack') { switch (_satellite.getDataElement('PageSection')) { case 'products' : case 'shop' : dataToCheck.push('ProductId'); eventId = 'pageViewProductView'; break; case 'register' : switch (_satellite.getDataElement('PageName')) { case 'welcome-to-our-club' : case 'welcome-offer' : eventId = 'pageViewRegistrationComplete'; dataToCheck.push('UserClubMemberId'); break; case 'personal-information' : eventId = 'pageViewRegistrationStart'; break; default: eventId = 'pageViewDefault'; break; } break; case 'checkout': dataToCheck.push('UserClubMemberId'); dataToCheck.push('Cart'); switch (_satellite.getDataElement('PageName')) { case 'shopping-bag': eventId = 'pageViewCheckoutshoppingBag'; break; case 'delivery-setup' : eventId = 'pageViewCheckoutDeliverySetup'; break; case 'order-confirmation' : eventId = 'pageViewCheckoutConfirmation'; dataToCheck.push('OrderId'); break; default : eventId = 'pageViewDefault'; break; } break; //if none of the above condition is met, then do a s.t() through the //default 'pageViewDefault' Direct Call Rule default: eventId = 'pageViewDefault'; break; }; doWhenReady('Check data for ' + eventId, todo, tocheck); } // Returning false here prevents _satellite from executing s.t() by default on any Page Load Rule : //if this code is set to take precedence over UI settings, this means you must have at least one //default Direct Call Rule which does it for all other pages of your website return false;

Avatar

Level 1

Benoit de Raemy wrote...

Hola a todos,

Resolvimos esto añadiendo un código personalizado que devuelve false  en el panel de la herramienta y / o Página Normas de carga "Personalizar Página de códigos".

En nuestro caso, nosotros no usamos Página Normas de carga, pero sólo directos Reglas de llamada para todas las páginas: ser capaz de rastrear páginaVer el contenido cargado assynchronous garantizando al mismo tiempo todos los datos necesarios se establecen incluso si se establecen después del último evento de carga de página disponible (domready), que impide que el seguimiento páginaVer defecto devolviendo false en el panel de la herramienta Analytics "Personalizar la página de códigos", y esto después de haber puesto en marcha una verificación iterativa del wich datos solicitados a continuación, activar la función Regla Llamada Directa, así:

  1. var appVersion = _satellite . getDataElement ( 'AppVersion' ),
  2. // DoWhenReady es un fn costumbre que ejecutar el tocheck fn cada 100 ms para un máximo de 10 veces:
  3. // Tocheck comprueba que el elemento de datos deseado (dataToCheck) se fijan y no está vacío
  4. // La función de TODO se ejecuta tan pronto como tocheck devuelve verdadero o al final de la iteración
  5. // (Un valor "DataElementName_missing" sería, al menos, estar mostrando en mis informes para que pueda instigar
  6. // Por qué este elemento de datos aún faltaría más de 1 segundo después se cargó guión _satellite)
  7. doWhenReady = doWhenReady || _satellite . getDataElement ( 'AYUDANTES doWhenReady' ),
  8. eventId , dataToCheck = [ 'UserLoginStatus' ], fn = función () { volver verdad ;},
  9. tocheck = función ( fn ) {
  10. var i = 0 , Isok = true ;
  11. fn = fn || función () { volver verdad ;};
  12. para ( i = 0 ; i < dataToCheck . longitud ; i ++) {
  13. // Aquí Elementos de datos son scripts personalizados que pueden devolver diferentes valores vacíos
  14. var dta = _satellite . getDataElement ( dataToCheck [ i ]);
  15. si ( dta === '' || dta === {} || dta === dataToCheck [ i ] + '_missing' || typeof dta === '' undefined || dta === 'undefined' ) {
  16. Isok = false ;
  17. romper ;
  18. }
  19. }
  20. retorno ( Isok && fn ())
  21. },
  22. TODO = función () {
  23. _satellite . pista ( eventId );
  24. };
  25. // Conmutar sentencias para definir qué Llamada Directa Regla para activar en función del contexto,
  26. // Por defecto a la regla llamada "pageViewDefault" directa
  27. si ( appVersion === 'theVersionToTrack' ) {
  28. interruptor ( _satellite . getDataElement ( 'PageSection' )) {
  29.  
  30. casos de 'productos' :
  31. caso "tienda" :
  32. dataToCheck . empuje ( 'ProductId' );
  33. eventId = 'pageViewProductView' ;
  34. romper ;
  35.  
  36. caso 'registrarse' :
  37. interruptor ( _satellite . getDataElement ( 'NombrePágina' )) {
  38.  
  39. caso 'bienvenida a nuestro club :
  40. caso 'welcome-oferta' :
  41. eventId = 'pageViewRegistrationComplete' ;
  42. dataToCheck . empuje ( 'UserClubMemberId' );
  43. romper ;
  44.  
  45. caso 'personal-información' :
  46. eventId = 'pageViewRegistrationStart' ;
  47. romper ;
  48.  
  49. default :
  50. eventId = 'pageViewDefault' ;
  51. romper ;
  52. }
  53. romper ;
  54.  
  55. caso 'checkout' :
  56. dataToCheck . empuje ( 'UserClubMemberId' );
  57. dataToCheck . empuje ( 'Cesta' );
  58. interruptor ( _satellite . getDataElement ( 'NombrePágina' )) {
  59.  
  60. caso 'shopping-bag' :
  61. eventId = 'pageViewCheckoutshoppingBag' ;
  62. romper ;
  63.  
  64. caso 'entrega-setup' :
  65. eventId = 'pageViewCheckoutDeliverySetup' ;
  66. romper ;
  67.  
  68. caso 'fin-de confirmación " :
  69. eventId = 'pageViewCheckoutConfirmation' ;
  70. dataToCheck . empuje ( 'OrderId' );
  71. romper ;
  72.  
  73. default :
  74. eventId = 'pageViewDefault' ;
  75. romper ;
  76.  
  77. }
  78. romper ;
  79. // Si se cumple ninguna de las condiciones anteriores, y luego hacer un st () a través de la
  80. // Defecto Regla Llamada Directa 'pageViewDefault'
  81. default :
  82. eventId = 'pageViewDefault' ;
  83. romper ;
  84.  
  85. };
  86.  
  87. doWhenReady ( 'Check datos para' + eventId , TODO , tocheck );
  88.  
  89. }
  90. // Volviendo falsa aquí _satellite impide ejecutar st () por defecto en cualquier regla de carga de la página:
  91. // Si este código es que tendrá prioridad sobre la configuración de interfaz de usuario, esto significa que debe tener por lo menos un
  92. // Regla por defecto llamada directa que lo hace para el resto de las páginas de su sitio web
  93. volver falsa ;

 

 

Avatar

Level 3

That looks great, thanks ... seems similar to s.abort flag in s_code.js !