-1

For google a 1 page visit = BOUNCE. My landing page is only 1 page so for Google ALL my page visits will be marked as a bounce.

I don't want to have BOUNCE RATE of 100℅ so to avoid this I need to create an EVENT TRACKING script.

By adding this EVENT TRACKING script to my page I can tell Google what I WANT to track as a bounce or not.

Events I want to track in landing page:

User spends 45 seconds in page = NO BOUNCE

User scrolls down 50℅ of page = NO BOUNCE

User watches video = NO BOUNCE

Bharti
  • 1
  • 1
  • 1

1 Answers1

2
  • User spends 45 seconds on a page

window.setTimeout(function() {
  ga('send', 'event', 'eventCategory', 'eventAction', 'eventLabel');
}, 45000);
  • User scrolls down page

/* GA Scroll Depth */
var body = document.body,
    html = document.documentElement,
    windowHeight = $(window).height(),
    fullPageHeight = Math.max( body.scrollHeight, body.offsetHeight,
                               html.clientHeight, html.scrollHeight, html.offsetHeight),
    scrollableHeight = fullPageHeight - windowHeight,
    quarterScrolledPos = Math.round(scrollableHeight * .25),
    halfScrolledPos = Math.round(scrollableHeight * .5),
    threeQuarterScrolledPos = Math.round(scrollableHeight * .75),
    quarterScrollSentToGA = false,
    halfScrollSentToGA = false,
    threeQuarterScrollSentToGA = false,
    fullScrollSentToGA = false;
function checkScrollDepth() {
  var scrollPos = $(document).scrollTop();
  if (scrollPos >= quarterScrolledPos) {
    if (!quarterScrollSentToGA) {
      sendScrollDepthToGa('25%');
      quarterScrollSentToGA = true;
    }
  }
  if (scrollPos >= halfScrolledPos) {
    if (!halfScrollSentToGA) {
      sendScrollDepthToGa('50%');
      halfScrollSentToGA = true;
    }
  }
  if (scrollPos >= threeQuarterScrolledPos) {
    if (!threeQuarterScrollSentToGA) {
      sendScrollDepthToGa('75%');
      threeQuarterScrollSentToGA = true;
    }
  }
  if (scrollPos === scrollableHeight) {
    if (!fullScrollSentToGA) {
      sendScrollDepthToGa('100%');
      fullScrollSentToGA = true;
    }
  }
}
function sendScrollDepthToGa(scrollHeight) {
  ga('send', 'event', 'Scroll Depth', 'scroll' + scrollHeight, urlPath);
}
$(window).on('scroll', checkScrollDepth);
/* END GA Scroll Depth */
  • Unless the video is set to auto-play, any click to start the video will count as an interaction with the page and will negate the bounce. However, if you still want to send an event to know that the video was played, you could use javascript to detect that the video was played and then send an event to GA such as:

  ga('send', 'event', 'video', 'play', 'someOtherData');

You may also want to look into non-interaction events: https://developers.google.com/analytics/devguides/collection/analyticsjs/events#non-interaction_events

Brian Norman
  • 514
  • 4
  • 13