Skip to content
Browse files

Enable google analytics tracking for email via sendgrid.

  • Loading branch information...
1 parent 37903ff commit 403f0835572b6a97e1acc847808d7300bba41769 @peregrinator peregrinator committed
Showing with 6 additions and 2 deletions.
  1. +1 −1 Gemfile.lock
  2. +5 −1 app/models/mailer.rb
View
2 Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/criticaljuncture/sendgrid.git
- revision: c3c7f99eb420ede23fecc63265e2f0d42fc61b8d
+ revision: 87d532bff3ab83ac5e842177a7b1fdaae39681b0
branch: master
specs:
sendgrid (0.1.5)
View
6 app/models/mailer.rb
@@ -2,7 +2,7 @@ class Mailer < ActionMailer::Base
include SendGrid
helper :entry, :text
- sendgrid_enable :opentracking, :clicktracking
+ sendgrid_enable :opentracking, :clicktracking, :ganalytics
def password_reset_instructions(user)
sendgrid_category "Admin Password Reset"
@@ -16,6 +16,7 @@ def password_reset_instructions(user)
def subscription_confirmation(subscription)
sendgrid_category "Subscription Confirmation"
+ sendgrid_ganalytics_options :utm_source => 'federalregister.gov', :utm_medium => 'email', :utm_campaign => 'subscription confirmation'
subject "[FR] #{subscription.mailing_list.title}"
from "Federal Register Subscriptions <subscriptions@mail.federalregister.gov>"
@@ -26,6 +27,7 @@ def subscription_confirmation(subscription)
def unsubscribe_notice(subscription)
sendgrid_category "Subscription Unsubscribe"
+ sendgrid_ganalytics_options :utm_source => 'federalregister.gov', :utm_medium => 'email', :utm_campaign => 'subscription unsubscribe'
subject "[FR] #{subscription.mailing_list.title}"
from "Federal Register Subscriptions <subscriptions@mail.federalregister.gov>"
@@ -38,6 +40,7 @@ def mailing_list(mailing_list, results, subscriptions)
sendgrid_category "Subscription"
sendgrid_recipients subscriptions.map(&:email)
sendgrid_substitute "(((token)))", subscriptions.map(&:token)
+ sendgrid_ganalytics_options :utm_source => 'federalregister.gov', :utm_medium => 'email', :utm_campaign => 'subscription mailing list'
toc = TableOfContentsPresenter.new(results)
agencies = toc.agencies
@@ -56,6 +59,7 @@ def mailing_list(mailing_list, results, subscriptions)
def entry_email(entry_email)
sendgrid_category "Email a Friend"
sendgrid_recipients entry_email.all_recipient_emails
+ sendgrid_ganalytics_options :utm_source => 'federalregister.gov', :utm_medium => 'email', :utm_campaign => 'email a friend'
subject "[FR] #{entry_email.entry.title}"
from entry_email.sender

0 comments on commit 403f083

Please sign in to comment.
Something went wrong with that request. Please try again.