VKirill

Скрипт копирования Email для GTM

Sep 29th, 2022
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. var c = document.getElementsByTagName("a");
  3. for(var i = 0; i < c.length; i++) {
  4.     if((typeof(c[i]) !== undefined) && (c[i].href.indexOf('mailto') !== -1)) {
  5.         c[i].addEventListener('copy', function(evt) {
  6.             dataLayer.push({
  7.             'event': 'copyText',
  8.             'copy-class' : evt.target.className
  9.             });
  10.         });
  11.         c[i].addEventListener('contextmenu', function(evt) {
  12.             dataLayer.push({
  13.             'event': 'rightClick',
  14.             'copy-class' : evt.target.className
  15.             });
  16.         });
  17.     }
  18. }
  19. </script>
Add Comment
Please, Sign In to add comment