Coder Social home page Coder Social logo

trackable-click's Introduction

TrackableClick

TrackableClick provides submit and link view helpers in ROR that can be tracked via Google analytic event, Google analytic e-commerce transaction, and Facebook pixel. It is implemented using unobtrusive Javascript and integrates via Railties.

Installation

Add this line to your application's Gemfile:

gem 'trackable-click'

And then execute:

$ bundle

Or install it yourself as:

$ gem install trackable-click

Add trackable click to your javascript manifest:

#= require trackable-click

Add GA snippet to your layout file (example in HAML):

- should_perform_tracking do
  :javascript
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-4JJHHJL9-1', {'cookieDomain':'none'});
    ga('send', 'pageview');

Enable trackable click via rails config:

Application.configure do
  config.tracking_clicks = true
end

Usage

1. submit example GA e-commerce
    = trackable_submit 'Place Order', google_commerce: {id:'1', affiliation: 'test product', revenue: '10.00', shipping:'0.00', tax:'0.00'}
2. submit example GA Event
    = trackable_submit 'Place Order', google_event: {action: 'click', label: 'User Placed Order'}, fp_pixel: {id: '6014085521316', value: '10.00', currency: 'USD'}
3. submit example Facebook Pixel
    = trackable_submit 'Place Order', fp_pixel: {id: '6014085521316', value: '10.00', currency: 'USD'}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

trackable-click's People

Contributors

cparratto avatar

Watchers

James Cloos avatar Sonja Hall 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.