Skip to content

Instantly share code, notes, and snippets.

@EmilienD
Created November 15, 2018 10:56
Show Gist options
  • Select an option

  • Save EmilienD/3ce58422d589edcae1381dab7e97a95c to your computer and use it in GitHub Desktop.

Select an option

Save EmilienD/3ce58422d589edcae1381dab7e97a95c to your computer and use it in GitHub Desktop.
Showing the current state of the dataLayer in a few lines of javascript
var dataLayerDisplayer = document.createElement('div')
dataLayerDisplayer.style= "font-size: 8; background-color: rgba(255,255,255,0.5); position: fixed; top:0; left: 0; z-index: 9001; max-height: 50vh; overflow: scroll;"
dataLayerDisplayer.id = "dataLayerDisplayer"
document.querySelector('body').append(dataLayerDisplayer)
setInterval(() => document.querySelector('#dataLayerDisplayer').innerHTML = JSON.stringify(dataLayer.concat().reverse(), null, 2).split('\n').join('<br>').split(' ').join('&nbsp;'), 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment