diff --git a/web/app/assets/javascripts/application.js b/web/app/assets/javascripts/application.js
index 55a45e8b4..9f73afcd2 100644
--- a/web/app/assets/javascripts/application.js
+++ b/web/app/assets/javascripts/application.js
@@ -16,5 +16,6 @@
//= require jquery.cookie
//= require jquery.Jcrop
//= require jquery.naturalsize
+//= require jquery.queryparams
//= require bootstrap
//= require_directory .
diff --git a/web/app/assets/javascripts/corp/corporate.js b/web/app/assets/javascripts/corp/corporate.js
index c720ba5d9..53108edd6 100644
--- a/web/app/assets/javascripts/corp/corporate.js
+++ b/web/app/assets/javascripts/corp/corporate.js
@@ -1,7 +1,9 @@
//= require jquery
+//= require jquery.queryparams
//= require AAC_underscore
//= require jamkazam
//= require utils
+//= require ga
//= require jam_rest
//= require corp/init
//= require_directory ../corp
\ No newline at end of file
diff --git a/web/app/assets/javascripts/ga.js b/web/app/assets/javascripts/ga.js
new file mode 100644
index 000000000..de010df01
--- /dev/null
+++ b/web/app/assets/javascripts/ga.js
@@ -0,0 +1,54 @@
+/**
+ * Common utility functions.
+ */
+(function(context,$) {
+
+ "use strict";
+
+ context.JK = context.JK || {};
+ var logger = context.JK.logger;
+
+ // types
+ var registrationTypes = {
+ native : "Native",
+ facebook : "Facebook"
+ }
+
+ var categories = {
+ register : "Register"
+ }
+
+ function assertBoolean(value) {
+ if(typeof value != 'boolean') {
+ throw "value is not a boolean: " + JSON.stringify(value);
+ }
+ }
+
+ function assertOneOf(enumValue, enums){
+ var found = false;
+ for (var key in enums) {
+ if (enumValue == enums[key]) {
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ throw "unable to find enum: " + enumValue + " in: " + JSON.stringify(enums);
+ }
+ }
+
+ function trackRegister(asMusician, registrationType) {
+ assertBoolean(asMusician);
+ assertOneOf(registrationType, registrationTypes);
+
+ var action = asMusician ? "Musician" : "Fan";
+
+ ga('send', 'event', categories.register, action, registrationType);
+ }
+
+ var GA = {};
+ GA.trackRegister = trackRegister;
+
+ context.JK.GA = GA;
+
+})(window,jQuery);
\ No newline at end of file
diff --git a/web/app/assets/javascripts/jquery.queryparams.js b/web/app/assets/javascripts/jquery.queryparams.js
new file mode 100644
index 000000000..fb99dc71c
--- /dev/null
+++ b/web/app/assets/javascripts/jquery.queryparams.js
@@ -0,0 +1,14 @@
+// from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values
+(function($) {
+ $.QueryString = (function(a) {
+ if (a == "") return {};
+ var b = {};
+ for (var i = 0; i < a.length; ++i)
+ {
+ var p=a[i].split('=');
+ if (p.length != 2) continue;
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
+ }
+ return b;
+ })(window.location.search.substr(1).split('&'))
+})(jQuery);
\ No newline at end of file
diff --git a/web/app/assets/javascripts/landing/congratulations.js b/web/app/assets/javascripts/landing/congratulations.js
index 3fafd07e0..646e4c525 100644
--- a/web/app/assets/javascripts/landing/congratulations.js
+++ b/web/app/assets/javascripts/landing/congratulations.js
@@ -4,56 +4,68 @@
var congratulations = {};
- congratulations.initialize = function initialize() {
+ function listClients() {
var rest = context.JK.Rest();
var currentOS = context.JK.detectOS();
var downloads = $('.downloads');
rest.getClientDownloads()
- .done(function(data) {
- downloads.removeClass('spinner-large');
+ .done(function(data) {
+ downloads.removeClass('spinner-large');
- var count = 0;
- for ( var property in data ) count++;
+ var count = 0;
+ for ( var property in data ) count++;
- if(count == 0) {
- alert("Currently unable to list client software downloads.");
- }
- else {
+ if(count == 0) {
+ alert("Currently unable to list client software downloads.");
+ }
+ else {
- $.each(data, function(key, item) {
+ $.each(data, function(key, item) {
- // if the currentOS we detect from browser is found within the product of an available client
- // we flag it with this boolean
- var matchesUserOS = currentOS != null && key.toLowerCase().indexOf(currentOS.toLowerCase()) > -1;
+ // if the currentOS we detect from browser is found within the product of an available client
+ // we flag it with this boolean
+ var matchesUserOS = currentOS != null && key.toLowerCase().indexOf(currentOS.toLowerCase()) > -1;
- var options = {
- emphasis: matchesUserOS ? "currentOS" : "",
- uri: item.uri,
- platform: key.substring('JamClient/'.length)
- }
+ var options = {
+ emphasis: matchesUserOS ? "currentOS" : "",
+ uri: item.uri,
+ platform: key.substring('JamClient/'.length)
+ }
- var download = context._.template($('#client-download-link').html(), options, {variable: 'data'});
+ var download = context._.template($('#client-download-link').html(), options, {variable: 'data'});
- if(matchesUserOS) {
- // make sure the current user OS is at the top
- downloads.prepend(download);
- }
- else {
- downloads.append(download)
- }
- });
- }
- })
- .fail(function() {
- downloads.removeClass('spinner-large');
- alert("Currently unable to list client software downloads due to error.");
- })
+ if(matchesUserOS) {
+ // make sure the current user OS is at the top
+ downloads.prepend(download);
+ }
+ else {
+ downloads.append(download)
+ }
+ });
+ }
+ })
+ .fail(function() {
+ downloads.removeClass('spinner-large');
+ alert("Currently unable to list client software downloads due to error.");
+ })
+ }
+ congratulations.initialize = function initialize(musician, registrationType) {
+ if(musician) {
+ listClients();
+ }
+
+ if(registrationType) {
+ $(function() {
+ // ga() object isn't ready until the page is loaded
+ context.JK.GA.trackRegister(musician, registrationType);
+ });
+ }
}
- window.congratulations = congratulations;
+ context.congratulations = congratulations;
})(window, jQuery)
\ No newline at end of file
diff --git a/web/app/assets/javascripts/landing/landing.js b/web/app/assets/javascripts/landing/landing.js
index 144b25c75..0646f8051 100644
--- a/web/app/assets/javascripts/landing/landing.js
+++ b/web/app/assets/javascripts/landing/landing.js
@@ -1,7 +1,9 @@
//= require jquery
+//= require jquery.queryparams
//= require AAC_underscore
//= require jamkazam
//= require utils
+//= require ga
//= require jam_rest
//= require landing/init
//= require landing/signup
diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb
index 75d60e7cc..714ed5506 100644
--- a/web/app/controllers/users_controller.rb
+++ b/web/app/controllers/users_controller.rb
@@ -92,9 +92,9 @@ class UsersController < ApplicationController
sign_in @user
if @user.musician
- redirect_to :congratulations_musician
+ redirect_to :action => :congratulations_musician, :type => 'Native'
else
- redirect_to :congratulations_fan
+ redirect_to :action => :congratulations_fan, :type => 'Native'
end
end
diff --git a/web/app/views/shared/_ga.html.erb b/web/app/views/shared/_ga.html.erb
index b6c0804e4..6b720c6e3 100644
--- a/web/app/views/shared/_ga.html.erb
+++ b/web/app/views/shared/_ga.html.erb
@@ -1,4 +1,4 @@
-<% if current_user.nil? || !current_user.admin? # remove admin users from GA %>
+<% if current_user.nil? || !Rails.application.config.ga_suppress_admin || !current_user.admin? # remove admin users from GA %>
\ No newline at end of file
diff --git a/web/app/views/users/congratulations_musician.html.erb b/web/app/views/users/congratulations_musician.html.erb
index 0f1146603..60d77f0e1 100644
--- a/web/app/views/users/congratulations_musician.html.erb
+++ b/web/app/views/users/congratulations_musician.html.erb
@@ -24,7 +24,7 @@