diff --git a/pb/Gemfile.lock b/pb/Gemfile.lock index 2dc14c3cc..d84fd06f1 100644 --- a/pb/Gemfile.lock +++ b/pb/Gemfile.lock @@ -10,7 +10,7 @@ DEPENDENCIES ruby-protocol-buffers (= 1.2.2) RUBY VERSION - ruby 2.3.1p112 + ruby 2.4.1p111 BUNDLED WITH - 1.17.3 + 2.2.15 diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 1af07266c..7632c7aa6 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -559,7 +559,7 @@ DEPENDENCIES zip-codes RUBY VERSION - ruby 2.3.1p112 + ruby 2.4.1p111 BUNDLED WITH 1.17.3 diff --git a/web/app/controllers/application_controller.rb b/web/app/controllers/application_controller.rb index d53082629..d092e08e2 100644 --- a/web/app/controllers/application_controller.rb +++ b/web/app/controllers/application_controller.rb @@ -65,10 +65,10 @@ class ApplicationController < ActionController::Base should_set = params[:utm_source] || origin.nil? if should_set if params[:utm_source] + cookies.permanent[:origin] = {utm_source: params[:utm_source], utm_medium: params[:utm_medium], utm_campaign: params[:utm_campaign], referrer: request.referrer }.to_json elsif request.referer - begin cookies.permanent[:origin] = {utm_source: "organic", utm_medium: "organic", utm_campaign: URI.parse(request.referer).host, referrer: request.referer}.to_json rescue diff --git a/websocket-gateway/Gemfile b/websocket-gateway/Gemfile index 7f9bf5508..3f2638424 100644 --- a/websocket-gateway/Gemfile +++ b/websocket-gateway/Gemfile @@ -45,6 +45,7 @@ gem 'redis', '3.3.3' # pinned until we are on 2.5; then remove gem 'redis-namespace', '1.5.3' # pinned until we are on 2.5; then remove gem 'oj', '3.1.3' # pinned until we are on 2.5; then remove gem 'bcrypt', '3.1.13' +gem 'mimemagic', :source => 'https://int.jamkazam.com/gems/' ####### diff --git a/websocket-gateway/Gemfile.lock b/websocket-gateway/Gemfile.lock index 601ea9fda..fb4987b4f 100644 --- a/websocket-gateway/Gemfile.lock +++ b/websocket-gateway/Gemfile.lock @@ -9,8 +9,9 @@ PATH jam_ruby (0.1.1) GEM - remote: https://rubygems.org/ + remote: http://rubygems.org/ remote: https://jamjam:blueberryjam@int.jamkazam.com/gems/ + remote: https://int.jamkazam.com/gems/ specs: CFPropertyList (2.3.6) aasm (5.1.1) @@ -572,6 +573,7 @@ DEPENDENCIES language_list logging mime-types (= 1.25.1) + mimemagic! netaddr (= 1.5.1) newrelic_rpm nokogiri (= 1.10.10) diff --git a/wordpress/plugins/jamkazam/jamkazam.php b/wordpress/plugins/jamkazam/jamkazam.php index 311ee3bfa..27bcc55fe 100644 --- a/wordpress/plugins/jamkazam/jamkazam.php +++ b/wordpress/plugins/jamkazam/jamkazam.php @@ -81,14 +81,7 @@ function run_jamkazam() { } run_jamkazam(); - - -/** -* Set affiliate tracking cookie if there is an `?affiliate=xxxx` parameter in the URL -* The rails set honors this cookie, and a new user will be associated with the affiliate. -*/ -add_action( 'init', 'process_post' ); -function process_post() { +function track_affiliate() { $affiliate_id = $_GET['affiliate']; $expiration = current_time( 'timestamp' ) + ( DAY_IN_SECONDS * 2 ); @@ -97,4 +90,22 @@ function process_post() { if(isset($affiliate_id)) { setcookie('affiliate_visitor', $affiliate_id, $expiration, '/', '.jamkazam.com'); } -} \ No newline at end of file +} + +function track_origin() { + $source = $_GET["utm_source"]; + + if(isset($source)) { + setcookie('origin', json_encode(array('utm_source' => $_GET['utm_source'], 'utm_medium' => $_GET['utm_medium'], 'utm_campaign' => $_GET['utm_campaign'])), strtotime( '+1 year' ), '/', '.jamkazam.com'); + } +} + +/** +* Set affiliate tracking cookie if there is an `?affiliate=xxxx` parameter in the URL +* The rails set honors this cookie, and a new user will be associated with the affiliate. +*/ +add_action( 'init', 'process_post' ); +function process_post() { + track_affiliate(); + track_origin(); +}