[Seaside] Seaside Access/Activity Logging

Sven Van Caekenberghe sven at beta9.be
Tue Aug 24 10:13:58 UTC 2010


Hi Boris,

On 24 Aug 2010, at 11:16, Boris Popov, DeepCove Labs (SNN) wrote:

> I would avoid web server logging in favour of modern tools like Google Analytics, which allow you to track user’s activity via variety of dimensions, one of which is, obviously, page’s URL. The following extract from one of our apps shows rendering of GA tracking code from updateRoot: that supports custom URL and multiple trackers (in our case we CC clients’ GA accounts using multiple tracker functionality new to asynchronous GA), but the key here is _trackPageview option which you can set to whatever free-form URL you choose instead of default Seaside’s URL. You can also add event tracking to all your links/buttons or otherwise apply a variety of options GA offers to suit your needs,
>  
> http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html
>  
> updateRoot: aHtmlRoot
>                 […]
> self session useAnalytics
>                                 ifTrue: [aHtmlRoot javascript with: (String streamContents: [:ws | self renderAnalyticsOn: ws])].
>                 […]
>  
> renderAnalyticsOn: stream
>  
>                 | trackers options |
>                 trackers := (Dictionary new)
>                                                                 at: '' put: 'UA-XXXXXXX-XX';
>                                                                 at: 'b.' put: 'UA-ZZZZZZZ-ZZ';
>                                                                 yourself.
>                 options := OrderedCollection new.
>                 trackers keysAndValuesDo:
>                                                 [:tracker :accountid |
>                                                 | forThirdParty |
>                                                 forThirdParty := tracker notEmpty.
>                                                 options add: (Array with: tracker , '_setAccount' with: accountid).
>                                                 forThirdParty
>                                                                 ifTrue:
>                                                                                 [options
>                                                                                                 add: (Array with: tracker , '_setDomainName' with: 'none');
>                                                                                                 add: (Array with: tracker , '_setAllowLinker' with: true);
>                                                                                                 add: (Array with: tracker , '_setAllowHash' with: false)].
>                                                 options add: (Array with: tracker , '_trackPageview' with: '/' , task trackingURL)].
>                 stream
>                                 nextPutAll: 'var _gaq = _gaq || [];';
>                                 nextPutAll: '_gaq.push('.
>                 options do: [:ea | stream json: ea] separatedBy: [stream nextPut: $,].
>                 stream nextPutAll: ');'.
>                 stream
>                                 nextPutAll: '(function() {';
>                                 nextPutAll: 'var ga = document.createElement(''script''); ga.type = ''text/javascript''; ga.async = true;';
>                                 nextPutAll: 'ga.src = (''https:'' == document.location.protocol ? ''https://ssl'' : ''http://www'') + ''.google-analytics.com/ga.js'';';
>                                 nextPutAll: 'var s = document.getElementsByTagName(''script'')[0]; s.parentNode.insertBefore(ga, s);';
>                                 nextPutAll: '})();'.
>  
> -Boris

Thx for the reply.
I understand your approach (even though I am not that deep into GA).
Still, the code you highlighted in red, task trackingURL, is that a method that you have to implement manually ?
I am looking for some hack that would log something meaningfull automagically ;-)

Sven



More information about the seaside mailing list