if (typeof window.view_ga !== 'undefined') {} else { window.view_ga = 1; (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); //ga('create', 'UA-200700137-1', 'auto', {'name': 'UA2007001371'}); //ga('UA2007001371.send', 'pageview'); //ga('create', 'UA-197492185-1', 'auto', {'name': 'UA1974921851'}); } if (typeof inViewport !== "function") { // safe to use the function function inViewport(element) { if (element) { var bb = element.getBoundingClientRect(); return !(bb.top > innerHeight || bb.bottom < 0); } } } if (typeof getViewtop !== "function") { function getViewtop(element) { if (element) { var bb = element.getBoundingClientRect(); return Math.ceil(bb.top / 100) * 100; } } } if (typeof bindviewnew !== "function") { function bindviewnew(myElements = { myElement: '', myElementid: 'post-10291', title: 'title', link: 'link' }) { //bindload(myElementid); console.log(myElements); var targetElement = document.getElementById(myElements.myElementid); //console.log(targetElement); document.addEventListener('scroll', event => { if (inViewport(targetElement)) { if (targetElement.getAttribute('viewed') == "2") { //ga('inread.send', 'event', 'viewnow', myElementid, location.href); targetElement.setAttribute("viewed", "1"); loaddata(myElements.title, myElements.link, getViewtop(targetElement)); //ga('inread.send', 'event', 'viewpose', myElementid, getViewtop(targetElement)); //ga('inread.send', 'event', 'loadlocate', myElementid, '' ); } else {} } else {} }) } } if (typeof loaddata !== "function") { function loaddata(pagetitle, pagelocation, pos) { pos = Math.ceil(window.scrollY / 100) * 100; console.log(pos+'_'+pagetitle); window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('event', 'page_view', { page_title: 'scroll_'+pos+'_'+pagetitle, page_location: encodeURI(pagelocation), send_to: 'UA-200700137-1' }) gtag('event', 'page_view', { page_title: 'scroll_'+pos+'_'+pagetitle, page_location: encodeURI(pagelocation), send_to: 'UA-197492185-1' }) gtag('event', 'view', { 'event_category': 'title', 'event_label': pos + '_' +pagetitle, send_to: 'UA-200700137-1' }) gtag('event', 'view', { 'event_category': 'title', 'event_label': pos + '_' + pagetitle, send_to: 'UA-197492185-1' }) gtag('event', 'view', { 'event_category': 'pos', 'event_label': pos, send_to: 'UA-200700137-1' }) gtag('event', 'view', { 'event_category': 'pos', 'event_label': pos, send_to: 'UA-197492185-1' }) } } if (typeof bindload !== "function") { function bindload(myElementid) { //ga('inread.send', 'event', 'load', myElementid, location.href); //ga('inread.send', 'event', 'loadlocate', myElementid, '' ); } } function loadview(myElements = { myElement: '', myElementid: 'post-10291', title: 'title', link: 'link' }) { console.log(myElements); if (document.getElementById(myElements.myElementid)) {} else { myElements.myElement.insertAdjacentHTML('afterEnd', '
'); bindviewnew(myElements); } } /* (function() { var myElements = { myElement: document.getElementById('post-10341'), myElementid: 'post-10341-view', title: 'title', link: 'link' }; loadview(myElements); })(); */