README.md in ahoy_email-2.0.0 vs README.md in ahoy_email-2.0.1
- old
+ new
@@ -198,12 +198,28 @@
<%= link_to "Go", some_url, data: {skip_utm_params: true} %>
```
## Click Analytics
-You can track click-through rate to see how well campaigns are performing. Stats can be stored in any data store, and there’s a built-in integration with Redis.
+You can track click-through rate to see how well campaigns are performing. Stats can be stored in your database, Redis, or any other data store.
+#### Database
+
+Run:
+
+```sh
+rails generate ahoy:clicks
+rails db:migrate
+```
+
+And create `config/initializers/ahoy_email.rb` with:
+
+```ruby
+AhoyEmail.subscribers << AhoyEmail::DatabaseSubscriber
+AhoyEmail.api = true
+```
+
#### Redis
Add this line to your application’s Gemfile:
```ruby
@@ -230,29 +246,31 @@
def track_click(data)
# your code
end
- def stats(campaign = nil)
+ def stats(campaign)
# optional, for AhoyEmail.stats
end
end
AhoyEmail.subscribers << EmailSubscriber
AhoyEmail.api = true
````
-### Setup
+### Usage
Add to mailers you want to track
```ruby
class CouponMailer < ApplicationMailer
track_clicks campaign: "my-campaign"
end
```
+If storing stats in the database, the mailer should also use `has_history`
+
Use only and except to limit actions
```ruby
class CouponMailer < ApplicationMailer
track_clicks campaign: "my-campaign", only: [:welcome]
@@ -285,16 +303,10 @@
AhoyEmail.default_options[:url_options] = {host: "mydomain.com"}
```
### Stats
-Get stats for all campaigns
-
-```ruby
-AhoyEmail.stats
-```
-
-Get stats for a specific campaign
+Get stats for a campaign
```ruby
AhoyEmail.stats("my-campaign")
```