Module: GoogleAnalyticsMailer

Defined in:
lib/google_analytics_mailer.rb,
lib/google_analytics_mailer/url_for.rb,
lib/google_analytics_mailer/version.rb

Overview

:nodoc:

Defined Under Namespace

Modules: GoogleAnalytics, UrlFor Classes: UriBuilder

Constant Summary collapse

VALID_ANALYTICS_PARAMS =

These are the currently GA allowed get params for link tagging

[:utm_source, :utm_medium, :utm_campaign, :utm_term, :utm_content]
VERSION =

Application version

'0.2.1'

Instance Method Summary collapse

Instance Method Details

#google_analytics_mailer(params = {}) ⇒ Object Also known as: google_analytics_controller

Enable google analytics link tagging for the mailer (or controller) which call this method

Parameters:

  • params (Hash) (defaults to: {})

    options for url to build

Options Hash (params):

  • :utm_campaign (String)

    required is the main GA param

  • :utm_content (String)

    content of the campaign

  • :utm_source (String)

    campaign source

  • :utm_medium (String)

    campaign medium

  • :utm_term (String)

    keyword for this campaign



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/google_analytics_mailer.rb', line 22

def google_analytics_mailer(params = {})
  if (params.keys - VALID_ANALYTICS_PARAMS).any?
    raise ArgumentError, "Invalid parameters keys #{params.keys - VALID_ANALYTICS_PARAMS}"
  end

  # add accessor for class level parameters
  cattr_accessor(:google_analytics_class_params) { params }

  # include the module which provides the actual functionality
  include GoogleAnalytics

end