const riotcontrol = require('riotcontrol');


const router = function() {

    let script = document.createElement('script');

    // function addBundle(route) {
    //     if (route) {
    //         script.src = 'build/Page.js'
    //     } else {
    //         script.src = 'build/Index.js'
    //     }
    //     document.body.appendChild(script);
    // }

    function onRoute(route, id, action) {
        riotcontrol.trigger('ROUTE', route);
        // addBundle(route);
    }

    riot.route(onRoute);
    riot.route.base('/#');
    riot.route.stop();
    riot.route.start(true);
};

module.exports = router();

const riotcontrol = require('riotcontrol');


function Router() {

    function setPageToTrack(route, subroute) {
        let page = '/';
        page += route ? (subroute ? route + '/' + subroute : route) : 'index';

        if (ga) {
            ga('set', 'page', page);
            ga('send', 'pageview');
        }
    }

    function onRoute(route, subroute) {
        riotcontrol.trigger('ROUTE', route);
        setPageToTrack(route, subroute);
    }

    riot.route(onRoute);
    riot.route.base('/#');
    riot.route.stop();
    riot.route.start(true);
};

module.exports = Router();

Send route to Google Analytics
Send route to Google Analytics
