Skip to content

Commit

Permalink
reapply ga tracking for updated api
Browse files Browse the repository at this point in the history
  • Loading branch information
moikaturns committed Nov 17, 2024
1 parent cfdb688 commit 4d887bd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 26 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-3321GFS477');
const MEASUREMENT_ID = 'G-3321GFS477';
gtag('config', MEASUREMENT_ID);
</script>
<body style="">
<div ng-view layout="column">
Expand Down Expand Up @@ -84,7 +84,7 @@
<script src="scripts/controllers/ColorGeneratorCtrl.js"></script>

<!-- Google Analytics snippet. -->
<!--
<!--
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
Expand All @@ -98,6 +98,6 @@
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
</script>
-->
!-->
</body>
</html>
8 changes: 2 additions & 6 deletions scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,12 @@ mcgApp.config(function ($routeProvider, $mdThemingProvider, $sceDelegateProvider
}
).run(function($rootScope, $location, $window, $mdTheming)
{
// initialise google analytics
// $window.ga('create', 'UA-62237624-1', 'auto');

// track index view
// $window.ga('send', 'pageview', 'mcg_index');
gtag('config', MEASUREMENT_ID, { 'page_path': 'mcg_index' });

// track pageview on state change
$rootScope.$on('$stateChangeSuccess', function (event) {
console.log(`'pageview' ${$location.path()}`);
// $window.ga('send', 'pageview', $location.path());
gtag('config', MEASUREMENT_ID, { 'page_path': $location.path() });
});

$mdTheming.generateTheme('default');
Expand Down
61 changes: 45 additions & 16 deletions scripts/controllers/ColorGeneratorCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
$scope.calcPalette($scope.palettes.length-1);

// Google Analytics Event Track
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Add Palette',
value: '1'
});
};

$scope.addPalettesFromLocation = function()
Expand Down Expand Up @@ -207,8 +212,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
$scope.deletePalette = function(key){
$scope.palettes.remove(key);
// Google Analytics Event Track
console.log(`'event' 'remove_palette'`);
//ga('send', 'event', 'mcg', 'remove_palette');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Remove Palette',
value: '1'
});
};

// Function to assign watchers to all bases
Expand Down Expand Up @@ -329,8 +337,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
$scope.showClipboard($scope.palettes, false);

// Google Analytics Event Track
console.log(`'event' 'copy_code_theme'`);
//ga('send', 'event', 'mcg', 'copy_code_theme');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Copy Theme',
value: '1'
});
};

$scope.forceNames = function(requireTwo)
Expand Down Expand Up @@ -395,8 +406,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
$scope.showClipboard(palette, true);

// Google Analytics Event Track
console.log(`'event' 'copy_code_palette'`);
//ga('send', 'event', 'mcg', 'copy_code_palette');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Copy Code Palette',
value: '1'
});
};

// Function to show export json for loading carts later
Expand Down Expand Up @@ -427,8 +441,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
}, function () { } );

// Google Analytics Event Track
console.log(`'event' 'import_code'`);
//ga( 'send', 'event', 'mcg', 'import_code' );
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Import Code',
value: '1'
});
};

/**
Expand Down Expand Up @@ -476,8 +493,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
});

// Google Analytics Event Track
console.log(`'event' 'run_demo'`);
//ga('send', 'event', 'mcg', 'run_demo');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Run Demo',
value: '1'
});
};

// Function to show export json for loading carts later
Expand All @@ -487,8 +507,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
$mdSidenav('settings').toggle();

// Google Analytics Event Track
console.log(`'event' 'settings'`);
//ga('send', 'event', 'mcg', 'settings');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Settings',
value: '1'
});
};

// Function to show export json for loading carts later
Expand All @@ -503,8 +526,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
} );

// Google Analytics Event Track
console.log(`'event' 'about_us'`);
//ga( 'send', 'event', 'mcg', 'about_us' );
gtag('event', 'click', {
event_category: 'Button',
event_label: 'About Us',
value: '1'
});
};

// Function to show generic clipboard alert dialog
Expand All @@ -524,8 +550,11 @@ function ($scope, $mdDialog, $rootScope, $mdColorPalette, $mdSidenav, $cookies,
});

// Google Analytics Event Track
console.log(`'event' 'copy_code'`);
//ga('send', 'event', 'mcg', 'copy_code');
gtag('event', 'click', {
event_category: 'Button',
event_label: 'Copy Code',
value: '1'
});
};

$scope.makeSafe = function(s){
Expand Down

0 comments on commit 4d887bd

Please sign in to comment.