Giter VIP home page Giter VIP logo

action_mailer_pixel's Introduction

ActionMailerPixel

ActionMailerPixel allows you to easily track your mailers' open rate.

How it works

When you enable the open tracking pixel on a mailer, a simple img tag will be inserted right before the closing body tag upon delivery. The source of the image tag leads to the /open.png path wherever you mounted the engine in your application. The response is a 1x1px transparent PNG image. When the email is opened by an email client, the pixel might get rendered (depending on the security/privacy settings) and the opening will be saved. Open rate is tracked by user and by email campaign. This way you can see exactly who opened a specific email.

Usage

1. Default (convention over configuration) - pixel is created with the first available of the following:

  • @user -> params[:user] -> recipient_class.find_by(email: message.to.first)
  • @campaign -> params[:campaign]
class PixelMailer < ApplicationMailer
  open_tracking_pixel

  def sample
    mail(to: '[email protected]')
  end
end

2. Explicit use - pixel is created with the provided data

class PixelMailer < ApplicationMailer
  open_tracking_pixel recipient: -> { params[:user] },
                      campaign:  -> { params[:campaign] }

  def sample
    mail(to: '[email protected]')
  end
end

Installation

Add this line to your application's Gemfile:

gem 'action_mailer_pixel'

And then execute:

$ bundle
$ bundle exec rails action_mailer_pixel:install:migrations
$ bundle exec rails db:migrate
$ bundle exec rails action_mailer_pixel:install

Mount the engine on a path of choice in config/routes.rb:

mount ActionMailerPixel::Engine => '/action_mailer_pixel'

Contributing

Contributions are welcome.

License

The gem is available as open source under the terms of the MIT License.

action_mailer_pixel's People

Contributors

st0yanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.