PHP と Google Analytics に問題があります。基本的に私がやりたいことは、ユーザーがGoogle Analytics<img src='path/to/image' />
のメールクライアントからメールからこの画像にアクセスしたときに訪問をカウントすることです。
// If is a view then just show an image
if($mysqlAction == "VIEW")
{
// Create a blank image and add some text
header('Content-Type: image/jpeg');
readfile('image.jpg');
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35932495-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
私の問題はその後です
// Create a blank image and add some text
header('Content-Type: image/jpeg');
readfile('image.jpg');
script.php
の出力はにアクセスするようなものになるため、コードを配置しても意味がありませimage.jpg
んが、実際には Google アナリティクスでビューをカウントする必要があります。
私が欲しいもの:
- どうすればこれを解決できますか?
- Sendblaster の TrackReports のような代替手段を提供しないでください...または同様のソリューション。
私のアイデアは次のとおりです。
- 私のアイデアは、最初にanalyticsコードを表示し
ob_flush()
てから画像を表示するようなダブルバッファを備えたものでした - 別のページか何かでフェッチ
CURL
... - PHP にアナリティクスを使用する ...
解決策はありますか?