jQuery(function($) {
  $.getJSON("/csrf.json").then(function(json) {
    $("meta[name=csrf-param]").attr("content", json.param);
    $("meta[name=csrf-token]").attr("content", json.token);

    var blockUI = function() {
      $.blockUI({ message: $(".spinner"), css: {backgroundColor: "none", border: "none"} });
    };

    var showFlash = function(message, status) {
      var name = (status === "success") ? "notice" : "alert";
      // fill the flash div with the message and the class for the flash type
      $(".flashes").html("<p class='flash " + name + "'>" + message + "</p>");
      // scroll so that the flash is on the screen, if needed
      $('html, body').animate({scrollTop: $(".flashes").offset().top}, 1000);
    };

    var doneFn = function(res) {
      $.unblockUI();
      if (res.url) {
        setTimeout(function() {
          document.location = res.url;
        }, 250);
      }

      if (res.message) {
        showFlash(res.message, res.result);
      }

      if (res.replace) {
        $(res.replace.selector).text(res.replace.text);
      }
    };

    var failFn = function(xhr, textStatus, errorThrown) {
      $.unblockUI();
      showFlash("Something went wrong. :(", "failure");
    };

    var recordConversion = function(type, value) {
      window._dcq = window._dcq || [];
      window._dcq.push(["track", type, { value: value }]);
    };

    var sendToken = function(el) {
      return function(token) {
        blockUI();
        var kind = el.data("subscription");

        var url = (kind === "update") ? "/membership/card" : "/membership";
        var data = {email: token.email, token: token.id, kind: kind};

        var val = el.data("dollar-amount")*100;
        recordConversion("Membership", val);

        $.post(url, data).done(doneFn).fail(failFn);
      };
    };

    $("a[data-subscription]").click(function(e) {
      var el = $(e.target);
      var kind = el.data("subscription");
      var amount = el.data("dollar-amount");

      var options = {
        description: el.data("subscription-name") + " ($" + amount + "/mo)",
        email: $(e.target).data("email"),
        image: "/images/rubies-square.png",
        key: $("meta[name=stripe-token]").attr("content"),
        name: "Ruby Together",
        panelLabel: "Subscribe",
        token: sendToken(el)
      };

      StripeCheckout.configure(options).open();
      e.preventDefault();
    });

    $("a[data-charge]").click(function(e) {
      var el = $(e.target);
      var amount = $("#" + el.data("amount-input")).val();

      var options = {
        description: "One-time contribution of $" + amount,
        email: $(e.target).data("email"),
        image: "/images/rubies-square.png",
        key: $("meta[name=stripe-token]").attr("content"),
        name: "Ruby Together",
        token: function(token) {
          blockUI();
          var url = "/charge";
          var data = {token: token.id, amount: amount, email: token.email};
          recordConversion("One Time", amount*100);
          $.post(url, data).done(doneFn).fail(failFn);
        }
      };

      StripeCheckout.configure(options).open();
      e.preventDefault();
    });
  });
});

@@ -1281,83 +1281,133 @@
     
-window._dcq = window._dcq %7C%7C %5B%5D;%0A      window._dcq.push(%5B%22track%22, type, %7B v
+ga('send', 'event', %7B%0A        eventCategory: %22Purchase%22,%0A        eventAction: %22new%22,%0A        eventLabel: type,%0A        eventV
 alue
@@ -1417,11 +1417,16 @@
 alue
+%0A     
  %7D
-%5D
 );%0A 
@@ -1751,20 +1751,16 @@
 amount%22)
-*100
 ;%0A      
@@ -3065,12 +3065,8 @@
 ount
-*100
 );%0A 

Switch to GA for conversion tracking