Google Analytics настраиваемые измерения для сеанса

Я пытаюсь получить более подробную информацию о сеансе, но я не уверен, как это сделать. Я хочу увидеть источник сессий. Определение, сколько из реферальных, прямых, социальных и электронной почты. Вот как я сейчас запрашиваю и печатаю результаты из API

// Query the API
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries the specified data
return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
'ga:Sessions,ga:avgSessionDuration,ga:bounceRate,ga:pageviews,ga:percentNewSessions,ga:pageviewsPerSession');
}function printResults(&$results) {
// Parses the response from the Core Reporting API and prints
// the profile name and total sessions.
if (count($results->getRows()) > 0) {

// Get the profile name.
$profileName = $results->getProfileInfo()->getProfileName();

// Get the entry for the first entry in the first row.
$rows = $results->getRows();
$visits = $rows[0][0];
$avgVisitDuration = $rows[0][1];
$bounceRate = $rows[0][2];
$pageView = $rows[0][3];
$percentNewSession = $rows[0][4];
$pagesPerVisit = $rows[0][5];
// Print the results.
echo '
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>

<table style="width:100%">
<tr>
<td>Total Visits</td>
<td>',$visits,'</td>
</tr>
<tr>
<td>Average Visit Duration</td>
<td>', floor($avgVisitDuration/ 60),' minutes ',$avgVisitDuration % 60,' seconds </td>
</tr>
<tr>
<td>Bounce Rate</td>
<td>',$bounceRate,' %</td>
</tr>
<tr>
<td>Page Views</td>
<td>',$pageView,'</td>
</tr>
<tr>
<td>Percentage New Visits</td>
<td>',$percentNewSession,' %</td>
</tr>
<tr>
<td>Pages / Visit</td>
<td>',$pagesPerVisit,'</td>
</tr>
</table>

</body>';} else {
print "No results found.\n";
}
}$analytics = getService();
$profile = getFirstProfileId($analytics);
$results = getResults($analytics, $profile);
printResults($results);

обновление: используя это измерение, я получаю ошибку синтаксиса ошибки, неожиданную »); ‘(T_CONSTANT_ENCAPSED_STRING), ожидая’) ‘на getResults в строке с’ ga ‘. ProfileID
вот как я пытаюсь запросить API

$optParams = array(
'dimensions' => 'ga:medium'
');
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries the specified data

return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
$optParams,
'ga:sessions');
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector