Class: SnowplowTracker::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/snowplow-tracker/page.rb

Overview

Note:

For Tracker#track_page_view, properties set in the Page object will override those properties given as arguments.

If the Ruby tracker is incorporated into a website server, the events tracked will describe user activity on specific webpages. Knowing on which page an event occurred can be very valuable.

Add page URL, page title and referrer URL to any event by adding a Page object to any Tracker #track_x_event method call.

Page parameters are saved into the tracked event as part of the 'atomic' event properties, which have their own column in the eventual events table. For example, a Page's page_url parameter will be sent as url in the raw event payload, ending up in the page_url column.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_url: nil, page_title: nil, referrer: nil) ⇒ Page

Create a Page object for attaching page properties to events.

Page properties will directly populate the event's page_url, page_title and referrer parameters.

Examples:

Creating a Page

SnowplowTracker::Page.new(page_url: 'http://www.example.com/second-page',
         page_title: 'Example title',
         referrer: 'http://www.example.com/first-page')

Parameters:

  • page_url (String) (defaults to: nil)

    the page URL

  • page_title (String) (defaults to: nil)

    the title of the page

  • referrer (String) (defaults to: nil)

    the URL of the previous page



49
50
51
52
53
# File 'lib/snowplow-tracker/page.rb', line 49

def initialize(page_url: nil, page_title: nil, referrer: nil)
  @details = { 'url' => page_url,
               'page' => page_title,
               'refr' => referrer }
end

Instance Attribute Details

#detailsHash (readonly)

Returns the stored page properties.

Returns:

  • (Hash)

    the stored page properties



35
36
37
# File 'lib/snowplow-tracker/page.rb', line 35

def details
  @details
end