Google Analytics on Helsinki Service Portal

brian_
Tera Guru

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

1 ACCEPTED SOLUTION

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.



find_real_file.png


(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.



find_real_file.png


View solution in original post

38 REPLIES 38

That certainly is an issue. If you went the UI script route, make sure it is not set to Global. That would put the tracking code on every page in ServiceNow. See my reply in this thread dated Dec 5, 2016 12:22 PM. That sounds like the issue here.


So as long as I uncheck Global on there, I should be good to go?


Yes. You can see the impact instantly if you go to the Real Time report in Google Analytics. You should see internal ServiceNow traffic fall off after changing that checkbox.


Looks good now, thanks Brian!


Hi Brian,



Question for you on the above - I am looking at using this for my HR Portal website and keen to understand if i have it setup correctly:



That will clean up your URL. The last thing you should do, is set your homepage name, and define search and filtering URL criteria. What this does is help GA condense /portalname and /portalame/index into the same page view (as they are), AND, by defining search URL criteria, you can use GA's advanced Site Search analytics.



These are both under View Settings. In "Default page" put index (unless you changed it). Enable Site search Tracking, and enter the letter q for the Query parameter



The URL for my portal is:   https://instancename.service-now.com/hrportal_dev



However instead of 'index' (which the Service Portal uses) my secondary link is:   https://instancename.service-now.com/hrportal_dev?id=hr_dashboard_cjf



What do I enter into the default page? - I entered the below but do I need anything else here?


find_real_file.png



Second question - regarding the 'Site Search Settings' - from your text i assume all we need to enter is the letter 'q' as below:



find_real_file.png



Thanks for your help with this.