The CreatorCon Call for Content is officially open! Get started here.

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

Check your browser's console for any error messages. Are there any?

Message from the Inspect Element -> Console Page

Andrew Pishchul
Giga Expert

Have you ever noticed that $locationChangeSuccess event sometimes causes a data inconsistency in GA stats: Page Title does not correspond to the Page URL?

 

This happens when $locationChangeSuccess fired, but Title of a new page has not been loaded yet. And if a new title has not been loaded yet that means when you're calling ga('send',... title: $window.document.title... you're actually sending a NEW url with the OLD page title. 

 

 

I'm running into this timing issue as well. Did you happen to implement a workaround for this?

Hi Andrew - were you able to figure this out? We're encountering the same issue now.