Skip to content

Commit 14f3c34

Browse files
committed
added partner tracking
1 parent 9f0551b commit 14f3c34

9 files changed

+69
-21
lines changed

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ source 'https://rubygems.org'
1515
# 2)WEBSERVER: Heroku/unbuntu/Mac uses thin so need gem execjs, therubyracer, thin
1616
# uncomment for ubuntu/thin and comment out for Windows
1717

18-
gem 'thin'
19-
gem 'execjs'
20-
gem 'therubyracer', '~> 0.10.2' #update to 0.11 crashes install
18+
# gem 'thin'
19+
# gem 'execjs'
20+
# gem 'therubyracer', '~> 0.10.2' #update to 0.11 crashes install
2121

2222

2323
# Gems used only for assets and not required

Gemfile.lock

+3-15
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,16 @@ GEM
3737
coffee-script-source
3838
execjs
3939
coffee-script-source (1.4.0)
40-
daemons (1.1.9)
4140
erubis (2.7.0)
42-
eventmachine (1.0.0)
4341
execjs (1.4.0)
4442
multi_json (~> 1.0)
4543
hike (1.2.1)
4644
i18n (0.6.1)
4745
journey (1.0.4)
48-
jquery-rails (2.1.4)
46+
jquery-rails (2.2.0)
4947
railties (>= 3.0, < 5.0)
5048
thor (>= 0.14, < 2.0)
5149
json (1.7.6)
52-
libv8 (3.3.10.4)
5350
mail (2.4.4)
5451
i18n (>= 0.4.0)
5552
mime-types (~> 1.16)
@@ -62,7 +59,7 @@ GEM
6259
rack (1.4.4)
6360
rack-cache (1.2)
6461
rack (>= 0.4)
65-
rack-ssl (1.3.2)
62+
rack-ssl (1.3.3)
6663
rack
6764
rack-test (0.6.2)
6865
rack (>= 1.0)
@@ -94,13 +91,7 @@ GEM
9491
multi_json (~> 1.0)
9592
rack (~> 1.0)
9693
tilt (~> 1.1, != 1.3.0)
97-
therubyracer (0.10.2)
98-
libv8 (~> 3.3.10)
99-
thin (1.5.0)
100-
daemons (>= 1.0.9)
101-
eventmachine (>= 0.12.6)
102-
rack (>= 1.0.0)
103-
thor (0.16.0)
94+
thor (0.17.0)
10495
tilt (1.3.3)
10596
treetop (1.4.12)
10697
polyglot
@@ -116,11 +107,8 @@ PLATFORMS
116107

117108
DEPENDENCIES
118109
coffee-rails (~> 3.2.1)
119-
execjs
120110
jquery-rails
121111
pg
122112
rails (= 3.2.11)
123113
sass-rails (~> 3.2.3)
124-
therubyracer (~> 0.10.2)
125-
thin
126114
uglifier (>= 1.0.3)

app/controllers/application_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ class ApplicationController < ActionController::Base
55

66
def set_tracking
77
!params[:src].nil? ? session[:src] = params[:src] : session[:src] = session[:src]
8+
!params[:cpg].nil? ? session[:cpg] = params[:cpg] : session[:cpg] = session[:cpg]
9+
!params[:adg].nil? ? session[:adg] = params[:adg] : session[:adg] = session[:adg]
10+
!params[:k].nil? ? session[:k] = params[:k] : session[:k] = session[:k]
11+
!params[:p].nil? ? session[:p] = params[:p] : session[:p] = session[:p]
12+
!params[:c].nil? ? session[:c] = params[:c] : session[:c] = session[:c]
813
end
914

1015
def set_secured_constants

app/controllers/partners_controller.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_url
1111
if l.lender_tail.nil?
1212
@lender_url = l.lender_link
1313
else
14-
@lender_url = l.lender_link + l.lender_tail + @page + @source
14+
@lender_url = l.lender_link + l.lender_tail + @conversion_key
1515
end
1616
end
1717

@@ -33,8 +33,12 @@ def redirect_values
3333
else
3434
@source = "0000"
3535
end
36+
#sets a random number sent to affiliates as variable
37+
@conversion_key=SecureRandom.hex(10)
38+
#saves ad campaign data conveersion_key to database
39+
Track.create(:src_code => @source, :page_code => @page, :campaign => session[:cpg], :ad_group => session[:adg], :kw => session[:k], :creative => session[:c], :placement => session[:p], :conversion_key => @conversion_key, :partner_id => params[:id])
3640
get_url
37-
@lender_url
41+
# @lender_url deleted this. not sure what it was doing.
3842
@lenders = Partner.all
3943
end
4044

app/models/track.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Track < ActiveRecord::Base
2+
attr_accessible :src_code, :page_code, :campaign, :ad_group, :kw, :creative, :placement, :conversion_key, :partner_id
3+
end
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class CreateTracks < ActiveRecord::Migration
2+
def change
3+
create_table :tracks do |t|
4+
t.string "conversion_key", :limit => 20
5+
t.string "src_code", :limit => 4
6+
t.string "page_code", :limit => 4
7+
t.string "campaign", :limit => 128
8+
t.string "ad_group", :limit => 255
9+
t.string "kw", :limit => 80
10+
t.string "creative", :limit => 25
11+
t.string "placement", :limit => 255
12+
t.integer "partner_id"
13+
t.timestamps
14+
end
15+
end
16+
end

db/schema.rb

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20121004212831) do
14+
ActiveRecord::Schema.define(:version => 20130129195942) do
1515

1616
create_table "lenders", :force => true do |t|
1717
t.integer "sniff_id"
@@ -189,4 +189,18 @@
189189
t.datetime "updated_at", :null => false
190190
end
191191

192+
create_table "tracks", :force => true do |t|
193+
t.string "conversion_key", :limit => 20
194+
t.string "src_code", :limit => 4
195+
t.string "page_code", :limit => 4
196+
t.string "campaign", :limit => 128
197+
t.string "ad_group"
198+
t.string "kw", :limit => 80
199+
t.string "creative", :limit => 25
200+
t.string "placement"
201+
t.integer "partner_id"
202+
t.datetime "created_at", :null => false
203+
t.datetime "updated_at", :null => false
204+
end
205+
192206
end

test/fixtures/tracks.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2+
3+
# This model initially had no columns defined. If you add columns to the
4+
# model remove the '{}' from the fixture names and add the columns immediately
5+
# below each fixture, per the syntax in the comments below
6+
#
7+
one: {}
8+
# column: value
9+
#
10+
two: {}
11+
# column: value

test/unit/track_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'test_helper'
2+
3+
class TrackTest < ActiveSupport::TestCase
4+
# test "the truth" do
5+
# assert true
6+
# end
7+
end

0 commit comments

Comments
 (0)