LAYOUT TEST

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.9 kB
7
Indexable
Never
//INITIALISATION DU LOADER DANS LES BALISES HEAD DE LA PLATEFORME
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://sdk.teester.com/loader.js";
document.getElementsByTagName("head")[0].appendChild(script);

// CALL BACK DE VERIFICATION PUIS PUSH DU SDK
window.onTeesterReady = window.onTeesterReady || [];
window.onTeesterReady.push(function (SDK) {

//EXEMPLE CARTER CASH
//RESSOURCES CLIENTS (CLES DES API)
var playerKey = "9d252ce0-6571-440e-9071-4bbbb9685d4f"
var trackingKey = "0cb15d84-4462-45bf-8c00-5cf5111cb5f2"

//PRODUCT ID 
var dataLayer = window.dataLayer || [];
var productId = dataLayer[3].ecommerce.detail.products[0].code8

//VERIFIER SI UNE VIDEO EST DISPONIBLE AVANT L'INITIALISATION DU SCRIPT 
SDK.checkVideoAvailability(playerKey, productId, function (value) {

  // DIV PARENTE CONTENANT LES ATTRIBUTS STYLISTIQUES DU PLAYER
  const divPlayer = document.createElement("div")
  divPlayer.setAttribute("id", "playerTeester");
  divPlayer.style.aspectRatio = "16/9";
  divPlayer.style.width = "650px";

  const player = SDK.init({
    type: 'player',
    args: {
       key: playerKey,
       product: productId,
       width: '100%',
       height: 'inherit'
    }
  }, 
  // ON ASSOCIE LE PLAYER A SA DIVPLAYER
  divPlayer);

  // RENDU DOM, POUR RAPPEL GRACE AU DEV TOOL => CLICK DROIT => INSPECTER L'ELEMENT => CLICK DROIT COPIER LE CHEMIN D'ACCES JS
  // APPEND pour afficher le player aprés l'élément selectionné, PREPEND pour afficher avant.
  
  document.querySelector("#accessory > div.main > div:nth-child(3) > div.description").append(divPlayer)

}); 

// TRACKING A INITIALISER APRES LA FONCTION SDK.CHECKVIDEOAVAILIBILTY 
const trackProductPage = SDK.init({
  type: 'tracking',
  args: {
      key: trackingKey,
      product: productId,
      event: 'PRODUCT_PAGE_VIEW'
  }
});


});