Sha256: d4e7f34f4786502aa028ce87c41374dc06af4f14b1d479ba5965c60beced619c

Contents?: true

Size: 847 Bytes

Versions: 8

Compression:

Stored size: 847 Bytes

Contents

# Handle Google Analytics behaviour
class this.GoogleAnalytics
  # Sets a read event for users viewing a page after a certain amount of seconds.
  # This is to create an adjusted bounce rate;
  # https://moz.com/blog/adjusted-bounce-rate
  @trackRead: ->
    minimumEngagementTimeInSeconds = 20

    setTimeout ( ->
      window.dataLayer = window.dataLayer || []
      dataLayer.push({ 'event': 'PageRead' })
    ), minimumEngagementTimeInSeconds * 1000

  # Set userId used by Google Analytics for User tracking
  @trackUser: ->
    window.dataLayer = window.dataLayer || []
    userid = $('body').data('user-id')
    dataLayer.push({ 'userid': userid })

  # Inform Google Tag Manager that a VirtualPageview has taken place
  @virtualPageView: ->
    window.dataLayer = window.dataLayer || []
    dataLayer.push({ 'event': 'VirtualPageview' })

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
integral-1.5.1 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.5.0 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.4.0 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.3.0 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.2.0 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.1.0 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.0.1 app/assets/javascripts/integral/support/google_analytics.coffee
integral-1.0.0 app/assets/javascripts/integral/support/google_analytics.coffee