[TYPO3-english] (no subject)

Mark Kuiphuis spam at markyourweb.com
Mon Jan 2 12:11:56 CET 2012


On 2/01/12 8:41 PM, Oliver Salzburg wrote:
> On 2012-01-02 07:01, Mark Kuiphuis wrote:
>> I always believe that if it can be solved with Typoscript, then it
>> should be done with Typoscript and not with an extension.... :-)
>>
>> I normally use the following Typoscript code to place the Google
>> Analytics code on every page:
>>
>> ##### START #####
>>
>> temp.gakey = TEXT
>>
>> [globalString = IENV:HTTP_HOST = {$HTTP_HOST_NL}]
>> temp.gakey.value = {$GA_KEY_NL}
>> [end]
>>
>> [globalString = IENV:HTTP_HOST = {$HTTP_HOST_EN}]
>> temp.gakey.value = {$GA_KEY_EN}
>> [end]
>>
>> [globalString = IENV:HTTP_HOST = {$HTTP_HOST_DE}]
>> temp.gakey.value = {$GA_KEY_DE}
>> [end]
>>
>> temp.analytics = COA
>> temp.analytics.10 = HTML
>> temp.analytics.10.value =<script type="text/javascript">
>> temp.analytics.20 = HTML
>> temp.analytics.20.value = var _gaq = _gaq || [];
>> temp.analytics.30 = HTML
>> temp.analytics.30<  temp.gakey
>> temp.analytics.30.wrap = _gaq.push(['_setAccount', '|']);
>> temp.analytics.40 = HTML
>> temp.analytics.40.value = _gaq.push(['_trackPageview']);
>> temp.analytics.50 = HTML
>> temp.analytics.50.value = (function() {
>> temp.analytics.60 = HTML
>> temp.analytics.60.value = var ga = document.createElement('script');
>> ga.type = 'text/javascript'; ga.async = true;
>> temp.analytics.70 = HTML
>> temp.analytics.70.value = ga.src = ('https:' ==
>> document.location.protocol ? 'https://ssl' : 'http://www') +
>> '.google-analytics.com/ga.js';
>> temp.analytics.80 = HTML
>> temp.analytics.80.value = var s =
>> document.getElementsByTagName('script')[0];
>> s.parentNode.insertBefore(ga, s);
>> temp.analytics.90 = HTML
>> temp.analytics.90.value = })();
>> temp.analytics.100 = HTML
>> temp.analytics.100.value =</script>
>>
>> # Add a newline character after almost any line (NOT AFTER THE unique
>> pagetracker ID)
>> temp.analytics.11 = HTML
>> temp.analytics.11.value.char = 10
>> temp.analytics.21 = HTML
>> temp.analytics.21.value.char = 10
>> temp.analytics.31 = HTML
>> temp.analytics.31.value.char = 10
>> temp.analytics.41 = HTML
>> temp.analytics.41.value.char = 10
>> temp.analytics.51 = HTML
>> temp.analytics.51.value.char = 10
>> temp.analytics.61 = HTML
>> temp.analytics.61.value.char = 10
>> temp.analytics.91 = HTML
>> temp.analytics.91.value.char = 10
>> temp.analytics.101 = HTML
>> temp.analytics.101.value.char = 10
>>
>> ##### END #####
>>
>> In the Constants (I normally use the root page) I define the GA_KEY_LLL
>> (where LLL = the language of that site)
>>
>> GA_KEY_NL = UA-1234567-1
>> GA_KEY_EN = UA-1234567-2
>> GA_KEY_DE = UA-1234567-3
>>
>> Then I build up the Google Javascript code here and put it in the<head>
>> section of your document just before the</head>...(apparently this is
>> new and allows it to work better and also work together with Google
>> Webmaster Tools...
>>
>> Of course this code can be simplified if you only have one GA account.
>> Then you don't need to use the conditions to set the proper UA code...
>>
>> On 27/12/11 9:55 PM, Francois Bertrand wrote:
>>> I was looking around the extensions on Typo3.org and came across this
>>> one:
>>> http://typo3.org/extensions/repository/view/we_google_analytics/current/
>>>
>>> What do you think about it? Is it better to use this one or tq_seo?
>>>
>>> Does it work well with the latest version of T3?
>>
>> Cheers, Mark
>
> The configuration for rs_googleanalytics looks like this btw:
>
> plugin.tx_rsgoogleanalytics {
>    account       = UA-XXX
>    registerTitle = title
> }
>
> Pick your favorite.

Hi,

Google has changed their javascript code over the years. If they do we have to wait 
for the extension developer of rsgoogleanalytics to come up with an updated version.

With the code I provided above everyone can update the code him/herself without 
waiting for the ext developer to come with an update. The extension also loads one or 
more PHP scripts, which is not necessary in this case...and the code is also based on 
piBase which works for now, but will not be supported anymore in the future. Hence my 
motivation to use Typoscript instead of an extension :D No hard feelings.....

My code can be halfed in size if I leave out the odd lines (11, 21, 31, etc. etc.) 
but then just all the js code is on one single line in the source code....

Cheers, Mark

PS I noticed that the extension does have a function to generate ecommerce tracking 
code for the commerce extension, something which is not in the Typoscript code I 
provided.


More information about the TYPO3-english mailing list