Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google analytics 如何使用GAPI和谷歌分析每天获得独特的访问者?_Google Analytics_Google Reporting Api - Fatal编程技术网

Google analytics 如何使用GAPI和谷歌分析每天获得独特的访问者?

Google analytics 如何使用GAPI和谷歌分析每天获得独特的访问者?,google-analytics,google-reporting-api,Google Analytics,Google Reporting Api,我在Google Analytics中有一个非常简单的自定义报告,列出某个月的日期、访问量、唯一访客和页面浏览量 我试图使用GAPI复制这个非常简单的报告,但是我找不到一个简单的方法来向我的表中添加唯一的访问者 请参阅下面的代码。如何修改此代码以显示唯一访问者 $profile_id = "xxxxxxxx"; $report_id = "xxxxxxxx"; $dimensions = array('date'); $metrics = array('pageviews','visits');

我在Google Analytics中有一个非常简单的自定义报告,列出某个月的日期、访问量、唯一访客和页面浏览量

我试图使用GAPI复制这个非常简单的报告,但是我找不到一个简单的方法来向我的表中添加唯一的访问者

请参阅下面的代码。如何修改此代码以显示唯一访问者

$profile_id = "xxxxxxxx";
$report_id = "xxxxxxxx";
$dimensions = array('date');
$metrics = array('pageviews','visits');
$sort_metric = array('date'); 
$filter = null;
$start_date = '2013-02-01';
$end_date = '2013-02-28';
$start_index = 1;
$max_results = 10000;

echo '<table>';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Visits</th>';
echo '<th>Unique Visitors</th>';
echo '<th>Page Views</th>';      
echo '</tr>';   

$ga = new gapi('xx@xxxxxxxxx.com','xxxxxxxx'); 

$ga->requestReportData($profile_id, $dimensions, $metrics, $sort_metric, $filter, $start_date, $end_date, $start_index, $max_results); 

foreach($ga->getResults() as $result)
{
    echo '<td>' . $result->getDate() . '</td>';
    echo '<td>' . $result->getVisits() . '</td>';
    echo '<td>' . '?' . '</td>';  
    echo '<td>' . $result->getPageviews() . '</td>';  
    echo '</tr>';  
}
echo "</table>";
$profile\u id=“xxxxxxxx”;
$report_id=“xxxxxxxx”;
$dimensions=数组('date');
$metrics=array('pageviews','visions');
$sort_metric=数组('date');
$filter=null;
$start_date='2013-02-01';
$end_date='2013-02-28';
$start_索引=1;
$max_结果=10000;
回声';
回声';
回音“日期”;
回应"访问",;
回应“独特访客”;
回应“页面浏览量”;
回声';
$ga=新的gapi('xx@xxxxxxxxx.com“,”xxxxxxxx“);
$ga->requestReportData($profile\u id、$dimensions、$metrics、$sort\u metric、$filter、$start\u date、$end\u date、$start\u index、$max\u results);
foreach($ga->getResults()作为$result)
{
回显“”。$result->getDate()。';
回显“”。$result->getvisions();
回音“.”?“.”;
回显“”。$result->getPageviews();
回声';
}
回声“;

该指标称为“访客”。尝试将其添加到您的报告中

度量称为访客和无访客,您必须将维度更改为
userDefinedValue

$profile_id = "xxxxxxxx";
$report_id = "xxxxxxxx";
$dimensions = array('userDefinedValue');
$metrics = array('pageviews','visits','visitors');
$sort_metric = array('date'); 
$filter = null;
$start_date = '2013-02-01';
$end_date = '2013-02-28';
$start_index = 1;
$max_results = 10000;

欢迎来到堆栈溢出。虽然这可能回答了问题,但提供更多关于这如何回答问题的信息将使这成为一个更好的答案。
$profile_id = "xxxxxxxx";
$report_id = "xxxxxxxx";
$dimensions = array('date');
$metrics = array('pageviews','visits','visitors');
$sort_metric = array('date'); 
$filter = null;
$start_date = '2013-02-01';
$end_date = '2013-02-28';
$start_index = 1;
$max_results = 10000;