December 28, 2013

Google Analytics with Siebel

I have seen couple of questions regarding use of Google Analytics with Siebel CRM, but no one seems to answer completely. This article is created to answer those questions.

When it comes to web analytics there is no parallel to Google Analytics, I am not selling Google Analytics, but people who have already used GA before can understand the need of powerful web analytics tools and how Google Analytics fills the gap.


This article will give you steps to create Google Analytics account and to embed the tracking code in Siebel.

Google Analytics can be used with Siebel CRM applications for both internal like Siebel Financial Services and external customer facing applications like eService or eSales. Only requirements from Google to use tracking are:
  • User must be able to reach the ga.js/analytics.js JavaScript file at http://www.google-analytics.com/ga.js or https://www.google-analytics.com/ga.js.
  • Intranet Application must be accessible through a fully qualified domain name such as http://intranet.example.com, application need not to be internet hosted application to use google analytics.

If your application can satisfy these requirements then you can create GA code and embed it to the Siebel Application.Once it is setup one can report on user behaviour demographic and many more metrics in GA.

I have used GA's Universal Analytics(newer version of GA) and created custom dimensions to store Active View Name, Application Name and Login User on Google.






Additionally I created events to capture the user interaction application. You can create event to business specific needs like: product configurator or service request creation or tasks.

How to embed Google Analytics tracker in Siebel Open UI?

Add the following code in postload.js file under the public directory, this code will be executed always when ever view is refreshed in Open UI. Code shown in bold is added after creation of dimension shown above.

(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');
  ga('create', 'YOUR_CODE', 'yoursitename');
  ga('send', 'pageview');
ga('set', 'dimension2', theApplication().GetProfileAttr("Login Name"));
ga('set', 'dimension1', theApplication().GetProfileAttr("ActiveViewName"));

ga('set', 'dimension3', theApplication().GetProfileAttr("ApplicationName"));
ga('send', 'event', theApplication().GetProfileAttr("ActiveViewName"), 'click', theApplication().GetProfileAttr("Login Name"));

How to embed Google Analytics with Siebel HI? 

Add following code to the  swecommon.js for high interactive applications, this js is also executed allways after page refresh in HI applications. 

(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');
  ga('create', 'YOURCODE', 'yoursitename');
  ga('send', 'pageview');
ga('set', 'dimension2', theApplication().GetProfileAttr("Login Name"));
ga('set', 'dimension1', theApplication().GetProfileAttr("ActiveViewName"));
ga('set', 'dimension3', theApplication().GetProfileAttr("ApplicationName"));
ga('send', 'event', theApplication().GetProfileAttr("ActiveViewName"), 'click', theApplication().GetProfileAttr("Login Name"));

Caution : Do not track customer information such as user details using custom dimesions and metrics as it is against the google analytics policy and could be against the organisation policy as well.

After all this is done you would be able to see the analytics information in your google account.










Now you can do full fledged analytics on your user interactions. My favorite is real time analytics, which one is your favorite??

Happy Analytics :)

11 comments :

  1. this is really an awesome idea!
    Thank you very much for sharing!!

    /Ben

    ReplyDelete
    Replies
    1. Thanks Ben for stopping by.
      Glad you like it

      - Jim

      Delete
  2. I can't get the dimension1-3 getting populated. In the code snippet you have (for example)

    ga('set', 'dimension2', theApplication().GetProfileAttr("Login Name"));

    Should that be double quotes around Login Name or single quotes?

    ReplyDelete
  3. Hi,

    In google analytics "Page Load/Average Page Load Time" is based on the browser API's "Navigation Timing API" ie "window.performance.timing.....". Once logged into the application the navigation is handled through the applicationcontext.js("SiebelApp.S_App" gotoview functionality) which uses the AJAX requests plus other resource loading, monitored through:"window.performance.getEntriesByType("resource")[i]" to load various pages, now this behavior makes the window.performance.timing.navigationStart and other various propertires constant throughout the navigation hence resulting in incorrect(zero in most cases) for "Page Load/Average Page Load Time".

    After searching on the various forums we could gather that "user timing api" can be used: "window.performance.mark" and "window.performance.measure" can be configured at various events/sites such as XMLHttpRequest.send(). If implemented, this would be an additional overhead.
    Can you please suggest a way through which we could correctly gather data for "Page Load/Average Page Load Time" without going with the extra customization, using only google analytics

    Sorry for the long question/explaination and waking up this pretty old thread.

    Thanks and Regards,
    Nalin

    ReplyDelete
    Replies
    1. Hi Nalin, Thanks for sharing your research. I would certainly like to help. As you said browser properties are constant, then we should try looking into the capturing the event in Open UI scripts, There should be some class who would be managing the SWE commands which we can hook into to capture the start of navigation command. It could be difficult to capture the end time. Dont worry about the overhead in marking the times it should be negligible as long as you are not syncing it with google everytime.

      I will try to research on this and post it here if I find anything interesting.

      -Jim

      Delete
    2. My last reply was misleading as Postload to Preload would only capture the loading of customized PM/PR if any for the specific view and any applet specific gifs. Before preload is called by the EventManger(contentmanager.js) through fireevent, XHR requests would have been completed.

      Regards,
      Nalin

      Delete
    3. preload.js and postload.js is definitely not the way to go, there is lot of processing before and beyond those files.

      - Jim

      Delete
  4. Thanks Jim for the quick reply, we are trying to look into the GA API, this link was of help:
    https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings

    What would you think would be the correct cycle of events to mark in Siebel Open UI (IP 2014), as to capture the most accurate page load time. Once the login/landing page is loaded all the main required css/js/gifs/images are loaded and inside application browsing just loads some XHR, gifs/images(to the specific screen/view) and custom PM/PR if any, of that specific screen/view.

    Preload to Postload seems a reasonably accurate cycle to capture.

    Regards,
    Nalin

    ReplyDelete
    Replies
    1. Nalin, I have gone through the link, it talks about judging the performance of your resources on the web page, it calculates it by asynchronously loading the elements, I don't think it will be possible to leverage that code in Open UI.

      I have investigated the contentmanager.js it looks promising, still I would spend some more time in finding another level deep to get more accurate stats.


      -Jim

      Delete
  5. Hi Jim.. We implemented the code as stated above for our dedicated client. But we cant see anything in our analytics dashboard. Is it available immediately considering the fact we signed up for this service on the same day?

    ReplyDelete
    Replies
    1. Hi Sumit, GA code should start working on same day. Check the code for any issues. Try putting the code in static HTML page first and see if GA records your interaction.

      Delete