README.md in ahoy_email-0.3.1 vs README.md in ahoy_email-0.3.2

- old
+ new

@@ -177,33 +177,43 @@ Subscribe to open and click events. Create an initializer `config/initializers/ahoy_email.rb` with: ```ruby class EmailSubscriber - def open(event) - # :message and :controller keys - ahoy = event[:controller].ahoy - ahoy.track "Email opened", message_id: event[:message].id + # any code you want end def click(event) - # same keys as above, plus :url - ahoy = event[:controller].ahoy - ahoy.track "Email clicked", message_id: event[:message].id, url: event[:url] + # any code you want end +end +AhoyEmail.subscribers << EmailSubscriber.new +``` + +Here’s an example if you use [Ahoy](https://github.com/ankane/ahoy) to track visits and events: + +```ruby +class EmailSubscriber + def open(event) + event[:controller].ahoy.track "Email opened", message_id: event[:message].id + end + + def click(event) + event[:controller].ahoy.track "Email clicked", message_id: event[:message].id, url: event[:url] + end end AhoyEmail.subscribers << EmailSubscriber.new ``` ## Reference You can use a `Proc` for any option. ```ruby -track utm_campaign: proc{|message, mailer| mailer.action_name + Time.now.year } +track utm_campaign: proc { |message, mailer| mailer.action_name + Time.now.year } ``` Disable tracking for an email ```ruby