Guest User

Untitled

a guest
Jan 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. (function(win) {
  2. var privateDataLayer = win.dataLayer || [];
  3.  
  4. Object.defineProperty(window, 'dataLayer', {
  5. get: function() {
  6. return privateDataLayer;
  7. },
  8. set: function(value) {
  9. if (value instanceof Array) {
  10. // In case there are multiple in the collection
  11. // I don't know what crazy person would do this
  12. value.forEach(function(val) {
  13. privateDataLayer.push(val);
  14. });
  15. }
  16. }
  17. })
  18. })(window);
Add Comment
Please, Sign In to add comment