- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2016 06:26 AM
Has anyone put Google Analytics on the Service Portal? I put it as a javascript include at the theme level. This seems to work, but only for the initial page the user hits or any refreshes. Since navigating around the portal typically doesn't involve reloading a new page, it would seem GA doesn't get the hit that the URL has changed.
I tried putting the tracking code into a widget in the header on all pages, but that didn't seem to work any better.
Any ideas? Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2016 12:09 PM
Did you create a UI script, or did you go through Service Portal > Themes > your theme > JS Includes? This is where the script will need to be. <edit: I re-read your post and saw you did that>
Also, remove the <script> tags (lines 1 & 10) from your script include. The yellow dot errors can be ignored.
That implementation should work great. I did end up combining that JS Include into the header widget as well for simplicity's sake. Here is a screenshot.
(if you choose to do it this way, you'll have to edit it in the Service Portal Configuration > Widget Editor. Editing it directly from Widgets will not let you save as the script editor barks at that red dot error, but that is code directly from Google so I left it alone)
And is working very well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 11:55 AM
Hi Brian,
I am trying to setup the GA with our SN instance. I have created an GA account and got the tracking ID. I have created the UI script as show above. Went to Service Portal -> Theme -> Selected an existing Theme and added the JS Include in the related list.
I dont see any changes happening in the GA Page. Please let me know if I am missing anything here.
UI Script:
function ($rootScope, $scope, snRecordWatcher, spUtil, $location, $uibModal, cabrillo, $timeout, $window){
(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','//www.google-analytics.com/analytics.js','ga');
gs('create', 'UA-Code xxxx, 'auto');
//browser load page view
ga('send', {
hitType: 'pageview',
title: $window.document.title,
location: $location.absUrl()
});
//angular navigate page view
$rootScope.$on('$locationChangeSuccess', function(event, toState, toParams){
ga('send', {
hitType: 'pageview',
title: $window.document.title,
location: $location.absUrl()
});
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 12:13 PM
The script you have posted here actually goes in the widget if you go that route (see the post marked as correct answer). It will be the entire client controller (plus of course any of your existing code). This method does not require a UI script to be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 12:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 12:53 PM
That is expected. I mentioned that right below the screenshot posted. You can save and ignore the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 01:44 PM