2011-03-11 12 views
6

Googleアナリティクスを使用して、特定のユーザーによるページビューとセッションをトラッキングします。 これを行うには、最新の(v1.1)GANTrackerバージョンでサポートされているカスタム変数を使用したいと思います。私はこれを入れて追跡したいページを開き、関数内iPhone SDKカスタム変数のGANTrackerでエラーが発生する195946409

error1: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)" 
error2: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)" 

:私は私のアプリを起動したとき

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxxx-x" 
             dispatchPeriod:10 
              delegate:nil]; 

NSError *error1; 
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:0 
                name:@"userSession" 
                value:@"username" 
                scope:kGANSessionScope 
               withError:&error1]){ 
    NSLog(@"error1 %@", error1); 
} 

NSError *error2; 
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:1 
                name:@"userSession" 
                value:@"username" 
                scope:kGANPageScope 
               withError:&error2]){ 
    NSLog(@"error2 %@", error2); 
} 

が、私はこれらのエラーを取得:私のappHeaderで

私はこのコードを持っています:

NSError * error; 
if(![[GANTracker sharedTracker] trackPageview:@"/pagename"] 
            withError:&error]){ 
     NSLog(@"%@", error); 
} 

これはエラーを返しません

setCustomVariableAtIndex関数を省略すると、ページビューはアナリティクスに記録されますが、カスタム変数とは何も得られません。

私はこの問題をどのように解決できるか考えている人はいますか?

+0

これを上記のコードを変更しますインデックス1を使用する必要があり、私は1で、インデックスを設定することにより、(私は思う)、それを解決し、2 0と1の代わりに – Weptunus

答えて

6

私は同じ問題に遭遇し、答えはGoogle's sample codeでつまずいた。

インデックスをゼロに設定すると、カスタム変数でエラーが発生します。あなたの最初の変数は、これは...このように見えるように、いくつかのグーグル場合

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxxx-x" 
             dispatchPeriod:10 
              delegate:nil]; 

NSError *error1; 
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:1 
                name:@"userSession" 
                value:@"username" 
                scope:kGANSessionScope 
               withError:&error1]){ 
    NSLog(@"error1 %@", error1); 
} 

NSError *error2; 
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:2 
                name:@"userSession" 
                value:@"username" 
                scope:kGANPageScope 
               withError:&error2]){ 
    NSLog(@"error2 %@", error2); 
} 
+0

私は無意識にnil値を渡して同じ(または非常に似たような)結果を達成することができました。 –

関連する問題