/** * Instantiate new class and push data * @param string $UA The UA string of the GA account to use * @param string $domain domain * @param string $page the page to set the pageview * @return null */ function ssga_track($UA = null, $domain = null, $page = null) { $ssga = new ssga($UA, $domain); $ssga->set_page($page); $ssga->send(); $ssga->reset(); return $ssga; }
<?php // 設定 define('GA_ACCOUNT', 'UA-51246207-2'); define('GA_HOST', 'shotawatanabe.com'); //ライブラリ include 'server-side-google-analytics/ss-ga.class.php'; // pageは必須 if (empty($_GET['page'])) { die("ERROR"); } // Create ssga instance $ssga = new ssga(GA_ACCOUNT, GA_HOST); // Set a pageview $ssga->set_page($_GET['page']); $ssga->set_page_title($_GET['title']); // Set Event $ssga->set_event('ContentBlocker', 'Fire', '', ''); // Send $ssga->send(); $ssga->reset();