Cookieを使って別サイトの閲覧履歴を取る
自社サイトを訪れたユーザが他サイトAを訪れたか調べたい。他サイトAに対してビーコンを貼れることを条件に、これが可能となる。
■他サイト側(http://sample.jp/index.html)
imgタグでビーコンを貼り付けてあげれば良い。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ドキュメント</title> </head> <body> <p><img src="http://sample.org/spacer.php" width="1" height="1" /></p> </body> </html>
■自社(サイト)ドメイン側実装
他サイトに貼り付けたビーコンを準備してあげる。
ビーコン用のイメージ(http://sample.org/spacer.php)
クッキーをセットしたいのでphpで書く。
<?php
header('Content-Type: image/gif');
setcookie('sample', 'see');
print(file_get_contents('spacer.gif'));
検証ページ(http://sample.org/index.php)
このページを訪問したユーザが、他サイトAを訪問したか調べられる。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>検証ページ</title>
</head>
<body>
<?php
if($_COOKIE['sample'] === 'see'){
print('<p>you have already seen http://sample.jp</p>');
}
else{
print('<p>Nice to meet you!</p>');
}
?>
</body>
</html>
基本的にはユーザの行動収集はこの原理で行う。iframeとJavaScriptを使用することで、さらに多くの情報を取得することができる。
TrackBack URL :
Comments (0)

