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

These both sound correct. You should be good with the above


Not sure if you still check this...  But, is including the JS include in the header necessary if it's already included in the theme?  In reverse, if it is included in the header widget, does it need to be in the them as an include?  I guess, can the google code snipped be in just one place or is it necessary in the theme and widget?

 

Thanks!

Hi Brian,



Is there a way where we can save the GA tracking code in a sys property or global variable so that we don't have to modify the 'UA-XXXX' code for every sub-prod and prod instances? Because we have different analytics property for DEV, QA and Prod the tracking codes are also different for each environment, hence the promotion cannot be controlled via update sets.



Thoughts?



Thank you!



Regards,


Mohammed Unwala


You should be able to set a system property, query that property and set it as a variable from the server script, and then access it and send that as your tracking code parameter in the client script. Just be sure you store the whole tracking code include the UA- in the system property. I didn't actually test this, but this should be what you need to incorporate. In the example, the system property is named "googleAnalyticsTracking"


sys_property_tracking_code.png


Thank you Brian for the suggestion, I will definitely try this out and let you know if it works.



So, when creating the sys property, i should be able to select 'string' as the type right even though my value will have a hyphen (UA-) in it?



Regards,


Mohammed Unwala