Created
March 1, 2012 21:45
-
-
Save ilyakatz/1953445 to your computer and use it in GitHub Desktop.
Mouseflow session support with Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
class Admin::MouseflowController < ApplicationController | |
#these are optional if you using authentication and ssl | |
skip_before_filter :authenticate_login! | |
def ssl_required? | |
false | |
end | |
def ssl_allowed? | |
true | |
end | |
######################################################## | |
def create | |
render :text=> mouseflow(params.slice('website', 'session', 'page', 'encoding', 'html', 'ajax', 'sequence', 'test')) | |
end | |
def index | |
render :text=> mouseflow(params.slice('test')) | |
end | |
protected | |
def mouseflow(post_args) | |
if post_args['test'] == '1' | |
post_args = {'website' => 'test'} | |
end | |
protocol = request.ssl? ? "https" : "http" | |
resp = Net::HTTP.post_form(URI.parse("#{protocol}://c.mouseflow.com/b.gif"), post_args) | |
resp.body | |
end | |
end | |
# Add this to your config/routes.rb file | |
#namespace :admin do | |
# resources :mouseflow, :only=>[:create, :index] | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment