Add Google Analytics on site.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Add Google Analytics on site.

Вася Чайко
Hello.

This my decision of a problem of addition google analytics on a site.

1. It is necessary to add one method in Class DefaultWebStyle:

googleAnalyticsTrackingCode: aString
    self app
        addHeader: 'script'
        value: #( 'type="text/javascript"' 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=''" + gaJsHost + "google-analytics.com/ga.js''  type=''text/javascript''%3E%3C/script%3E"));' ).
    self app
        addHeader: 'script'
        value: (Array
            with: 'type="text/javascript"'
            with: 'var pageTracker = _gat._getTracker("' , aString , '"); pageTracker._initData(); pageTracker._trackPageview();').

2. In style of a site to add a method:

htmlHeaderElements
    super htmlHeaderElements.
    self googleAnalyticsTrackingCode: 'UA-2231739-3'. "tracking code for site"
    "other header elements"

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida

DefaultWebStyle-googleAnalyticsTrackingCode.st (992 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add Google Analytics on site.

Nicolas Petton
Hi,

Your solution will work, but a more elegant way would be to use a component for that, and include it where you want, for example by overriding #pageFrame:with: in your webstyle class.

I have a GoogleAnalyticsComponent somewhere, I will share it as soon as I find it ;)

Cheers!

Nico

2008/9/16 Вася Чайко <[hidden email]>
Hello.

This my decision of a problem of addition google analytics on a site.

1. It is necessary to add one method in Class DefaultWebStyle:

googleAnalyticsTrackingCode: aString
    self app
        addHeader: 'script'
        value: #( 'type="text/javascript"' 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=''" + gaJsHost + "google-analytics.com/ga.js''  type=''text/javascript''%3E%3C/script%3E"));' ).
    self app
        addHeader: 'script'
        value: (Array
            with: 'type="text/javascript"'
            with: 'var pageTracker = _gat._getTracker("' , aString , '"); pageTracker._initData(); pageTracker._trackPageview();').

2. In style of a site to add a method:

htmlHeaderElements
    super htmlHeaderElements.
    self googleAnalyticsTrackingCode: 'UA-2231739-3'. "tracking code for site"
    "other header elements"

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida




--
Nicolas Petton

http://nico.bioskop.fr

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida