3

FileLibraryの使い方を実装しました。

次に、次のコードを使用します。

updateRoot:anHtmlRoot

super updateRoot: anHtmlRoot.
anHtmlRoot title: self title.
anHtmlRoot link beShortcutIcon; url: MyfileLibrary  / #myGraphicPng.
anHtmlRoot javascript url: (MyFileLibrary urlOf: #analyticsJs)

グーグルはページをチェックしますが、実数を取得することはありません。常に「データを待機中」の状態です。

ヒントや例をいただければ幸いです。

4

2 に答える 2

3

Google Analytics は Seaside とうまく連携します。私は何年もの間、多くの (主に桟橋ベースの) シーサイド サイトで使用してきました。

  1. #analyticsJsに正しい Google アナリティクス トラッキング コードが含まれていることを確認してください。コードを script タグにインライン化する方がはるかに効率的です (そして Google によって提案されています) が、URL を使用しても機能すると思います。

  2. アプリケーションが完全修飾ドメイン名 (FQDN) で実行されていることを確認してください。ではトラッカーが機能しないと思います。詳細については、 Google アナリティクスのヘルプlocalhostを参照してください。

于 2011-01-18T03:36:34.783 に答える
3

以下は、複数のトラッカー (たとえば、CC 追跡データをクライアントのアカウントに送信するため)、カスタム変数、および URL 生成をサポートする、もう少し複雑な (逐語的な) 例です。

updateRoot: ルート

super updateRoot: root.
root javascript with: (String streamContents: [:ws | self renderAnalyticsOn: ws]).

renderAnalyticsOn: ストリーム

| options |
options := OrderedCollection new.
self trackingConfiguration keysAndValuesDo: 
        [:tracker :accountid |
        | isForClient |
        isForClient := tracker notEmpty.
        options add: (Array with: tracker , '_setAccount' with: accountid).
        isForClient
            ifTrue: 
                [options
                    add: (Array with: tracker , '_setDomainName' with: 'none');
                    add: (Array with: tracker , '_setAllowLinker' with: true);
                    add: (Array with: tracker , '_setAllowHash' with: false)].
        self trackingCustomVariables do: 
                [:array |
                array at: 1 put: tracker , array first.
                options add: array].
        options add: (Array with: tracker , '_trackPageview' with: '/' , self 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: '})();'.

追跡構成

| trackers |
trackers := (Dictionary new)
            at: '' put: 'UA-XXXX-YY';
            yourself.
self session googleAnalytics ifNotNil: [:v | trackers at: 'b.' put: v].
^trackers.

追跡カスタム変数

^Array with: (Array
                with: '_setCustomVar'
                with: 1
                with: 'Application'
                with: self class applicationName
                with: 2).

トラッキング URL

^String streamContents: [:ws | crumbs do: [:ea | ws nextPutAll: ea title asAnalyticsURL] separatedBy: [ws nextPut: $/]].

asAnalyticsURL

^self asLowercase copyReplace: Character space with: $_
于 2011-01-18T09:54:24.620 に答える