A ruby gem for Muvandy API
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Gemfile
LICENSE
README.md
Rakefile
muvandy.gemspec

README.md

Muvandy

Client for Muvandy API

Installation

Add this line to your application's Gemfile:

	gem 'muvandy', '~> 1.2.2a1'

And then execute:

$ bundle

Or install it yourself as:

$ gem install muvandy --pre

To Configure

Create a file in your config/initializers folder named muvandy_setup.rb (or whichever name you prefer)

	Muvandy.configure do |c|
		c.api_key = 'api_key_here'
	end

Add include Muvandy in your controllers/application_controller.rb.

	class ApplicationController < ActionController::Base
	  include Muvandy
	
		...
	end

Get Variations

Controller

Example of using muvandy on a controller.

	class HomeController < ApplicationController
		def index
			@muvandy = Muvandy.new('experiment_id', :visitor_key => request.remote_ip)
		end
	end

A visitor_key is required. By default, we recommend using the visitor's IP address but if you have other information on them their account id or email address make good unique visitor identifiers.

Views

Get the value by providing variable key and a fallback text. Fallback text will be displayed if in case muvandy returns an error for the variable.

	<%= content_tag "h1", @muvandy.get_variation("Headline-1", "Greetings!") %>
	<p>
		<%= @muvandy.get_variation("main-text-1") %>
	</p>

Conversions

	class HomeController < ApplicationController
		include Muvandy
		
		...
		
		def thank_you
		
			...
			
			Muvandy::convert('experiment_id', :visitor_key => request.remote_ip)
		end
	end