Google Analytics code for multiple GCEM Sites
Hello, i have updated the index.html file located here to include the Google Analytics code for multiple Gecortex sites i have.
inetpub\wwwroot\Html5Viewer\Index.html
The first site i have located in the file is being tracked effectively by Google Analytics but the other two, not so much. Is there some glaring error in my code as it currently stands? Any help is appreciated
The full Index.html file code is found below:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Geocortex Viewer for HTML5</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="apple-touch-icon" href="Resources/Images/Icons/iOS/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="72x72" href="Resources/Images/Icons/iOS/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="76x76" href="Resources/Images/Icons/iOS/apple-touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="Resources/Images/Icons/iOS/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="120x120" href="Resources/Images/Icons/iOS/apple-touch-icon-iphone-retina.png" />
<link rel="apple-touch-icon" sizes="144x144" href="Resources/Images/Icons/iOS/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon" sizes="152x152" href="Resources/Images/Icons/iOS/apple-touch-icon-ipad-retina.png" />
<link rel="stylesheet" href="Resources/Styles/splash.css" />
</head>
<body>
<!-- Splash Screen Markup -->
<div class="splash-overlay">
<img class="splash-pre-loader" src="Resources/Images/loader-small.gif" alt="" />
<div class="splash-plate splash-invisible">
<img class="splash-image" alt="" />
<p class="splash-paragraph">This application uses licensed Geocortex Essentials technology for the Esri<sup>®</sup> ArcGIS platform. All rights reserved.
<!-- Standard GVH Embed -->
<script src="Resources/Compiled/loader.js"></script>
<script>
// Uncomment the below line to only use local copies of Esri API files. This is done automatically in the Geocortex Mobile App Framework.
//var geocortexUseLocalEsriApi = true;
var viewerConfig = {
"configurations": {
"default": "Resources/Config/Default/" + shellName + ".json.js",
"pdsmapportal": "http://dmc-gis1.snoco.co.snohomish.wa.us/Geocortex/Essentials/REST/sites/TheMapPortal_1/viewers/The_Map_Portal1/virtualdirectory/Resources/Config/Default/" + shellName + ".json.js",
"pdsigallery": "http://dmc-gis1.snoco.co.snohomish.wa.us/Geocortex/Essentials/REST/sites/MapApp_v3/viewers/MapApp_HTML/VirtualDirectory/Resources/Config/Default/" + shellName + ".json.js",
},
"viewerConfigUri": null
};
new geocortex.essentialsHtmlViewer.ViewerLoader().loadAndInitialize();
/*
This function parses the QUERY GET variables encoded in the URL. By calling the function with the 'viewer' variable, we
can get the name of the viewer being loaded. For example, if the URL is http://dmc-gis1.snoco.co.snohomish.wa.us/Html5Viewer/Index.html?viewer=pdsmapportal
than the value of getUrlParameter('viewer') will == 'pdsmapportal' indicating that we should load map portal specific code in an if block or otherwise do
something special.
Based on http://stackoverflow.com/questions/19491336/get-url-parameter-jquery-or-how-to-get-query-string-values-in-js (Accepted answer, Sameer Kazi Feb 20, 2014)
*/
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
// Get the name of the viewer and convert to lowercase
var viewerName = getUrlParameter('viewer').toLowerCase();
// Do stuff for each viewer
if(viewerName == 'pdsmapportal'){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-89243185-1', 'auto');
ga('send', 'pageview');
} else if(viewerName == 'pdsigallery') {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-89259798-1', 'auto');
ga('send', 'pageview');
};
} else if(viewerName == 'activepermits') {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96448853-1', 'auto');
ga('send', 'pageview');
};
</script>
</body>
</html>
0
-
Hi Raoul,
It looks like your code runs the same Google Analytics functions regardless of the viewer that was detected. Each branch is sending the "pageview" event, but there is no way for Google Analytics to know which Geocortex Viewer is associated with that pageview, to my knowledge.
I'm not super familiar with the way Google Analytics works, but it looks like they have lots of options out there for tracking.
The Viewer for HTML5 could be classified as a Single Page Application:
https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications
So, maybe give some of those instructions a try to track the viewer with Google Analytics.
Regards,
-Malcolm0 -
Raoul,
This is how we have ours setup. We put the tracking code on the same index.html file and then I can check the specific site under Behavior-->Site Content--> All Pages
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=90760000000Grp2&feoid=Body&refid=0EM60000000Ujva" _/_img_0 -
We do the same thing as Scott. We created Segments with conditions based on the viewer URL. (Page contains "viewer=<viewername>") 0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare