简体   繁体   中英

Using GAPI how do I get visitor count on each page?

Like the old days, I like to have visitor counting or page hits on each page on my website, which will be different on each page. Using GAPI I can get total visitor but it will be the same figure on each page, but I can't find the parameter to count on each page.

Here's my code so far:

    define('ga_email','mymail@example.com');
    define('ga_password','password');
    define('ga_profile_id','xxxxxxxx');
    require 'gapi.class.php';
    $ga = new gapi(ga_email,ga_password);
    $ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pageviews','visits'));
    echo $ga->getVisits();

To get the visitor count for each page, you have to break down the desired metrics using the ga:pagePath dimension. This dimension contains the path and query parameters of a pageview. If you track multiple domains, add the ga:hostname dimension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM