Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Load Type Changes
Browse files Browse the repository at this point in the history
So we can track the difference between frontend and admin page loads
  • Loading branch information
fredbradley authored Dec 3, 2017
1 parent 64459a4 commit 4b29aa4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,25 @@ public static function run( string $analytics_id=null ) {
}

public static function googleanalytics() {

?>
if (is_admin()) {
$loadType = "adminLoad";
} else {
$loadType = "frontendLoad";
}

?>
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="//www.googletagmanager.com/gtag/js?id=<?php echo self::$analytics_id; ?>"></script>
<script>
var url = '<?php echo $_SERVER['REQUEST_URI']; ?>';
var loadType = '<?php echo $loadtype; ?>';

window.dataLayer = window.dataLayer || [];
function frbtagnagios(){dataLayer.push(arguments)};
frbtagnagios('js', new Date());

frbtagnagios('config', '<?php echo self::$analytics_id; ?>');
frbtagnagios('event', 'load', {
frbtagnagios('event', loadType, {
'event_category': "<?php echo get_bloginfo('name'); ?>",
'event_label': url,
'transport_type': 'beacon'
Expand Down

0 comments on commit 4b29aa4

Please sign in to comment.