JSFiddle - React, Tailwind, and code Playground

by gajjargaurav

HTML

analytics.js

JavaScript

// Define MoneyVista namespace if not already defined
var MoneyVista = MoneyVista || {};

MoneyVista.Analytics = (function (settings) {
    // If there are no settings passed then we throw - can't do much without it
    if (!settings)
        throw "MoneyVista.analytics has been called without first setting up MoneyVista.analyticsParameters";

    // GOOGLE ANALYTICS -------------------------------------------------------
    var Google = (function () {

        return {
            TrackPageView: function (pageName) {
                // If we don't have any settings then we can't proceed
                if (!window._gaq)
                    throw "Error calling MoneyVista.Analytics.Google - are the google tracking scripts injected?";
                if (pageName)
                    window._gaq.push(['_trackPageview', '/' + pageName]);
                else
                    window._gaq.push(['_trackPageview']);
            },

            TrackSubscriptionSuccess: function (userId, paymentReference, cost, frequency) {
                // If we don't have any settings then we can't proceed
                if (!window._gaq)
                    throw "Error calling MoneyVista.Analytics.Google - are the google tracking scripts injected?";

                window._gaq.push(['_addTrans', paymentReference, 'MoneyVista', cost]);

                window._gaq.push(['_addItem', paymentReference, frequency, frequency + ' subscription', 'Subscription', cost, '1']);

                window._gaq.push(['_trackTrans']);
            },
            
            TrackEvent: function (category, action) {
                if (!window._gaq)
                    throw "Error calling MoneyVista.Analytics.Google - are the google tracking scripts injected?";
                
                window._gaq.push(['_trackEvent', category, action]);
            }
        };

    })();
    // GOOGLE ANALYTICS -------------------------------------------------------

    // CLICK DIMENSIONS...