getパラメーターの値で表示を切り替えます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <table> <?php if ( $_GET [ "selectedDimension" ] == 'continent' ): ?> <th>Continent</th><th>Users</th> <?php $i = 0; foreach ( $c1 as $key => $value ){ if ( $i < 10){ echo "<tr>" ; echo "<td>" . $key . "</td><td>" . $value . "</td>" ; echo "</tr>" ; } $i ++; } ?> </table> <?php elseif ( $_GET [ "selectedDimension" ] == 'country' ): ?> <th>Country</th><th>Users</th> <?php $i = 0; foreach ( $c2 as $key => $value ){ if ( $i < 10){ echo "<tr>" ; echo "<td>" . $key . "</td><td>" . $value . "</td>" ; echo "</tr>" ; } $i ++; } ?> </table> <?php elseif ( $_GET [ "selectedDimension" ] == 'city' ): ?> <th>City</th><th>Users</th> <?php $i = 0; foreach ( $c3 as $key => $value ){ if ( $i < 10){ echo "<tr>" ; echo "<td>" . $key . "</td><td>" . $value . "</td>" ; echo "</tr>" ; } $i ++; } ?> </table> <?php else : ?> <th>Page</th><th>PageView</th> <?php $i = 0; foreach ( $data as $key => $value ){ if ( $i < 10){ echo "<tr>" ; echo "<td>" . $key . "</td><td>" . $value . "</td>" ; echo "</tr>" ; } $i ++; } ?> </table> <?php endif ; ?> |
continent
country
city
一人デバックしてるなー
というか、これ、ページビュー単位ではなくて、cookie単位しないと駄目だ
うおおおおおおお、結構複雑だ
cookieに重複がない場合だけ、ipの地域を取得するに変更
foreachの前で$cookie=array();と宣言します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | $cookie = array (); foreach ( $cursor as $document ) { $pv [] = $document -> date ; if (!in_array( $document ->cookie, $cookie )){ if (! is_null ( $document ->continent)){ $c1 [] = $document ->continent; } if (! is_null ( $document ->contry)){ $c2 [] = $document ->contry; } if (! is_null ( $document ->city)){ $c3 [] = $document ->city; } } $cookie [] = $document ->cookie; $session [] = $document ->session; if (! is_null ( $document ->referrer)){ $avgtime [] = $document ->avgtime; } if (! is_null ( $document ->referrer)){ $referrer [] = $document ->referrer; } $visit [] = $document ->visit; $access [] = substr ( $document -> date , 11, 2); $page [] = $document ->page; } |
continent, country, cityがuniqueになりました。
よっしゃ、ip周りはOKそう。
次は、browser, os, service provider
これ、js、phpでとれるんか?
取れなければ、スキップとしたい。が、GAでは必ず見る項目ではある。。