• Resolved Hamed.T

    (@hamedt)


    Hi, thank you for publishing this useful plugin, i want to ask that can i put your script into a .js file with my analytics?
    like this:

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-12345678-9']);
    _gaq.push(['_trackPageview']);
    (function () {
        var ga = document.createElement('script');
        ga.type = 'text/javascript';
        ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(ga, s);
    })();
    
    var _gaq = _gaq || [];
    (function (tos) {
        window.setInterval(function () {
            tos = (function (t) {
                return t[0] == 50 ? (parseInt(t[1]) + 1) + ':00' : (t[1] || '0') + ':' + (parseInt(t[0]) + 10);
            })(tos.split(':').reverse());
            window.pageTracker ? pageTracker._trackEvent('Time', 'Log', tos) : _gaq.push(['_trackEvent', 'Time', 'Log', tos]);
        }, 10000);
    })('00');

    https://www.ads-software.com/plugins/reduce-bounce-rate/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    That’s possible, no problem.

    If you want to add the code without plugin you could also use this code. It sends an event to Analytics every 10 seconds, but also every time when they scroll down the page.

    <script type="text/javascript">
    var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
     _gaq.push(['_trackPageview']);
    setTimeout(function() {
     window.onscroll = function() {
     window.onscroll = null; // Only track the event once
     _gaq.push(['_trackEvent', 'scroll', 'read']);
     }
     }, 10000);
    (function() {
     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'https://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();
    </script>
    Thread Starter Hamed.T

    (@hamedt)

    but what if my page not scrollable?

    Plugin Author Okoth1

    (@okoth1)

    Hi,

    The code above is OK. If you do scroll, no event will be send to Analytics, but it still sends an event every 10 seconds.

    Thread Starter Hamed.T

    (@hamedt)

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘put script in a .js file’ is closed to new replies.