683 lines
21 KiB
PHP
683 lines
21 KiB
PHP
<?php
|
|
|
|
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../fonctions/authplugins.php");
|
|
|
|
|
|
|
|
/* Thelia 1.4 ne charge pas les classes automatiquement ..*/
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/Lang.class.php");
|
|
|
|
|
|
|
|
if(function_exists('autorisation')) autorisation("ganalytics");
|
|
|
|
require_once(realpath(dirname(__FILE__)) . "/gapi.class.php");
|
|
|
|
require_once(realpath(dirname(__FILE__)) . "/Ganalytics.class.php");
|
|
|
|
$Ganalytics = new Ganalytics();
|
|
|
|
$lang = new Lang();
|
|
|
|
|
|
|
|
$langues_configurees = $Ganalytics->getLanguesConfigurees();
|
|
|
|
$ga_langue_defaut = $Ganalytics->getLangueDefaut();
|
|
|
|
|
|
|
|
if(sizeof($langues_configurees) > 0){ ?>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../client/plugins/ganalytics/stylesheets/gui.css" type="text/css" media="screen" title="timeframe" charset="utf-8"/>
|
|
|
|
<link rel="stylesheet" href="../client/plugins/ganalytics/stylesheets/timeframe.css" type="text/css" media="screen" title="timeframe" charset="utf-8"/>
|
|
|
|
<link rel="stylesheet" href="../client/plugins/ganalytics/stylesheets/ga.css" type="text/css" media="screen" charset="utf-8"/>
|
|
|
|
<script src="../client/plugins/ganalytics/scripts/jquery/jquery.js" type="text/javascript"></script>
|
|
|
|
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
|
|
|
<script src="../client/plugins/ganalytics/scripts/jquery.scrollTo-min.js" type="text/javascript"></script>
|
|
|
|
<div id="ganalytics">
|
|
|
|
<div class="entete_liste" style="height:24px;margin-left:10px;margin-right:10px">
|
|
|
|
<div class="titre">STATISTIQUES GOOGLE ANALYTICS
|
|
|
|
<select id="galang" name="galang"><?php
|
|
|
|
foreach($langues_configurees as $langue){ ?><option value="<?php echo $langue['id'] ?>"><?php echo $langue['description'] ?></option><?php }?>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div id="ga-loader"><img src="../client/plugins/ganalytics/images/ajax-loader.gif" /></div>
|
|
|
|
</div>
|
|
|
|
<div id="example" style="margin-left:10px;margin-right:10px">
|
|
|
|
<div id="calendar_form"><?php
|
|
|
|
echo $Ganalytics->displayCalendar(date("d-m-Y"),date("d-m-Y")); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="ga-results"><?php
|
|
|
|
|
|
|
|
$_mailGA = $Ganalytics->getVar('mailGA');
|
|
|
|
$_passGA = $Ganalytics->getVar('passGA');
|
|
|
|
$_urlsiteGA = $Ganalytics->getVar('urlsiteGA'.$ga_langue_defaut);
|
|
|
|
$_profGA = $Ganalytics->getVar('profGA'.$ga_langue_defaut);
|
|
|
|
|
|
|
|
//die($_mailGA->valeur.' => '.$_passGA->valeur.' => '.$_urlsiteGA->valeur.' => '.$_profGA->valeur);
|
|
|
|
|
|
|
|
# Définition du domaine par défaut
|
|
|
|
$domain = $Ganalytics->GetDomain($Ganalytics->getUrlSite());
|
|
|
|
|
|
|
|
# Définition du domaine pour la langue sinon on garde celui par défaut
|
|
|
|
if($Ganalytics->is_sup_15()) if($lang->charger_id($ga_langue_defaut)) if($lang->url != '') $domain = $Ganalytics->GetDomain($lang->url);
|
|
|
|
elseif(!empty($_urlsiteGA->valeur)) $domain = $_urlsiteGA->valeur;
|
|
|
|
|
|
|
|
$ga = $Ganalytics->getGapi($_mailGA->valeur,$_passGA->valeur);
|
|
|
|
$ga_aw = $Ganalytics->getGapi($_mailGA->valeur,$_passGA->valeur);
|
|
|
|
|
|
|
|
$date_depart = date("Y-m-d");
|
|
|
|
$date_fin = date("Y-m-d");
|
|
|
|
|
|
|
|
// requestReportData($report_id, $dimensions, $metrics, $sort_metric=null, $filter=null, $start_date=null, $end_date=null, $start_index=1, $max_results=30)
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('date'),
|
|
|
|
array('visits', 'pageviews', 'pageviewsPerVisit' , 'revenuePerTransaction' , 'transactionsPerVisit' , 'percentNewVisits' , 'transactions',
|
|
|
|
'avgTimeOnSite', 'entranceBounceRate', 'totalValue'), null, null, $date_depart, $date_fin);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
|
|
|
|
$ga_aw->requestReportData($_profGA->valeur, array('date','adDestinationUrl'),
|
|
|
|
array('impressions','adClicks','adCost','CPC','CTR','transactionRevenue'), null, 'adDestinationUrl=@'.$domain, $date_depart, $date_fin);
|
|
|
|
$results_aw = $ga_aw->getResults();
|
|
|
|
|
|
|
|
echo '<br /><br /><div id="page-analtyics" style="display:none">';
|
|
|
|
echo '<div class="metric"><span class="label">Visites</span><strong id="liveVisits">'.number_format($ga->getVisits()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Pages vues</span><strong>'.number_format($ga->getPageviews()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Pages vues / visite</span><strong>'.round($ga->getPageviewsPerVisit(), 2).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Taux de rebond</span><strong>'.round($ga->getEntrancebouncerate(), 2).'%</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Durée moyenne</span><strong>'.secondMinute($ga->getAvgtimeonsite()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Nouvelle visite</span><strong>'.round($ga->getPercentNewVisits(), 2).'%</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Conversion</span><strong>'.round($ga->getTransactionsPerVisit(), 2).'%</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Transactions</span><strong>'.number_format($ga->getTransactions()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">C.A (hors port)</span><strong>'.round($ga->getTotalValue(), 2).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Panier moyen</span><strong>'.round($ga->getRevenuePerTransaction(), 2).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Impressions AdWords</span><strong id="liveVisits">'.number_format($ga_aw->getImpressions()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Clics AdWords</span><strong>'.number_format($ga_aw->getAdClicks()).'</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Coût AdWords</span><strong>'.round($ga_aw->getAdCost(), 2).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">CPC AdWords</span><strong>'.round($ga_aw->getCPC(), 2).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">CTR AdWords</span><strong>'.round($ga_aw->getCTR(), 2).'%</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">C.A par clic AdWords</span><strong>'.( 0 == $ga_aw->getAdClicks() ? '0' : round($ga_aw->getTransactionRevenue() / $ga_aw->getAdClicks(), 2)).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">Marge AdWords</span><strong>'.round($ga_aw->getTransactionRevenue() - $ga_aw->getAdCost(), 2).' €</strong></div>';
|
|
|
|
echo '<div class="metric"><span class="label">ROI AdWords</span><strong>'.( 0 == $ga_aw->getTransactionRevenue() ? 'N.A' : round(($ga_aw->getTransactionRevenue() - $ga_aw->getAdCost()) / $ga_aw->getAdCost() * 100, 2).'%').'</strong></div>';
|
|
|
|
echo '<div style="clear: left;"></div>';
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
$js = drawChart('visits','chart','Visites',$ga,$_profGA->valeur,null,$date_depart,$date_fin); ?>
|
|
|
|
<div id="ga-blocinfossup"><?php
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('source','medium'), array('visits'), '-visits', 'visits>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">VISITES PAR SOURCE</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
<?php echo couper_texte_html($result->getSource(), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getMedium().'</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo $result->getVisits() ?></li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('source','medium'), array('totalValue'), '-totalValue', 'totalValue>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">C.A PAR SOURCE</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
<?php echo couper_texte_html($result->getSource(), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getMedium().'</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo $result->getTotalValue() ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('productName'), array('itemRevenue'), '-itemRevenue', NULL, $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">C.A PAR PRODUIT</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>"><span title="<?php echo $result->getProductName() ?>" ><?php echo
|
|
|
|
couper_texte_html($Ganalytics->cleanEncodage($result->getProductName()), 30, $ending = '...', $exact = true) ?></span></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo $result->getItemRevenue() ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
} ?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="ga-blocinfossup"><?php
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('source','medium'), array('visits','totalValue'), '-totalValue', 'totalValue>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">VALEUR PAR VISITE</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
|
|
|
|
<?php echo couper_texte_html($result->getSource(), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getMedium().'</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getTotalValue() / $result->getVisits(),2) ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('source','medium'), array('visits','transactions'), '-transactions', 'transactions>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">TAUX DE TRANSFORMATION</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
<?php echo couper_texte_html($result->getSource(), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getMedium().'</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getTransactions() / $result->getVisits() * 100,2).$Ganalytics->cleanEncodage('%') ?></li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('source','medium'), array('visits','totalValue','transactions'), '-totalValue', 'totalValue>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">PANIER MOYEN</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
<?php echo couper_texte_html($result->getSource(), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getMedium().'</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getTotalValue() / $result->getTransactions(),2) ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
} ?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="ga-blocinfossup"><?php
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('keyword','adDestinationUrl'), array('CTR'), '-CTR', 'CTR>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">CTR ADWORDS</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
|
|
|
|
<?php echo couper_texte_html($Ganalytics->cleanEncodage($result->getKeyword()), 30, $ending = '...', $exact = true) ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getCTR(),2) ?>%</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('keyword','adDestinationUrl'), array('CPC'), '-CPC', 'CPC>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">CPC ADWORDS</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
|
|
|
|
<?php echo couper_texte_html($Ganalytics->cleanEncodage($result->getKeyword()), 30, $ending = '...', $exact = true) ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getCPC(),2) ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
}
|
|
|
|
$ga->requestReportData($_profGA->valeur, array('keyword','adDestinationUrl'), array('adCost','adClicks'), '-adCost', 'adCost>0', $date_depart, $date_fin,1,10);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
if(count($results) > 0){?>
|
|
|
|
<ul><li class="entete">COÛT ADWORDS</li><?php
|
|
|
|
$i = 1;
|
|
|
|
foreach($results as $result){
|
|
|
|
$ligne = ($i % 2) ? 'claire' : 'fonce';
|
|
|
|
if($i == sizeof($results)) $ligne = ($ligne == 'claire') ? 'lignebottom' : 'lignebottomfonce' ?>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:184px; background-color:#9eb0be;<?php if ($ligne == 'claire' OR $ligne == 'fonce') echo 'border-bottom: 1px dotted #FFF' ?>">
|
|
|
|
|
|
|
|
<?php echo couper_texte_html($Ganalytics->cleanEncodage($result->getKeyword()), 16, $ending = '...', $exact = true).' <span class="ga_medium">'.$result->getAdClicks().' visite(s)</span>' ?></li>
|
|
|
|
<li class="<?php echo $ligne ?>" style="width:110px;"><?php echo round($result->getAdCost(),2) ?> €</li><?php
|
|
|
|
$i++;
|
|
|
|
}?></ul><?php
|
|
|
|
} ?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="blocmid" style="display:none">
|
|
|
|
<div class="entetemid"><div class="titre">Visites</div></div>
|
|
|
|
<div id="chart"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8"><?php
|
|
|
|
echo $js; ?>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</div></div>
|
|
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
|
|
|
|
|
|
function refreshStats(date_depart,date_fin,compare){
|
|
|
|
if(!compare){compare = "";}
|
|
|
|
$("#datepickerFrom").val(date_depart);
|
|
|
|
$("#datepickerTo").val(date_fin);
|
|
|
|
$("#compare").val(compare);
|
|
|
|
$("#submitDatePicker").click();
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery(document).ready(function($){
|
|
|
|
if ($("form#calendar_form .datepicker").length > 0){
|
|
|
|
$("form#calendar_form .datepicker").datepicker({
|
|
|
|
prevText: '',
|
|
|
|
nextText: '',
|
|
|
|
dateFormat: 'dd-mm-yy'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$("#ganalytics").before( $("#bloc_informations") );
|
|
|
|
$("#example").append( $("#page-analtyics"));
|
|
|
|
$("#page-analtyics").fadeIn();
|
|
|
|
$('#galang').change(function(){
|
|
|
|
$('#submitDatePicker').click();
|
|
|
|
});
|
|
|
|
$('#submitDatePicker').click(function(){
|
|
|
|
$('#ga-loader').show();
|
|
|
|
var date_depart = $('#datepickerFrom').val().replace(/-/g,'/');
|
|
|
|
var date_fin = $('#datepickerTo').val().replace(/-/g,'/');
|
|
|
|
var compare = $('#compare').val();
|
|
|
|
var galang = $('#galang').val();
|
|
|
|
$.ajax({type:"GET",
|
|
|
|
cache:false,
|
|
|
|
url:"../client/plugins/ganalytics/ga-results.php?date_depart=" + date_depart + "&date_fin=" + date_fin + "&galang=" + galang + "&compare=" + compare,
|
|
|
|
success:
|
|
|
|
function(data){
|
|
|
|
data = data.split('|Js2Execute|');
|
|
|
|
$('#ga-loader').hide();
|
|
|
|
$('#ga-results').css('height','1200px');
|
|
|
|
$("#page-analtyics").css('display','none');
|
|
|
|
$("#page-analtyics").attr('id','page-analtyics-tmp');
|
|
|
|
$('#ga-results').empty();
|
|
|
|
$('#ga-results').html(data[0]);
|
|
|
|
$('#ga-results').css('height',$('#ganalytics').height() + 'px');
|
|
|
|
$("#example").append( $("#page-analtyics"));
|
|
|
|
$.scrollTo('#ganalytics',30);
|
|
|
|
$("#page-analtyics").slideDown('fast',function(){
|
|
|
|
$("#page-ganalytics-tmp").remove();
|
|
|
|
});
|
|
|
|
// alert(data[1]);
|
|
|
|
eval(data[1]);
|
|
|
|
},
|
|
|
|
error: function(w,t,f) {
|
|
|
|
alert(w + "\n" + t + "\n" + f);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script><?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawChart($name,$id_cible,$columnName,$ga,$_profGA,$filter = NULL,$date_depart = NULL,$date_fin = NULL){
|
|
|
|
$ga->requestReportData($_profGA, array('date'),array($name), 'date', $filter, $date_depart, $date_fin);
|
|
|
|
$results = $ga->getResults();
|
|
|
|
$donnees = '';
|
|
|
|
switch($name){
|
|
|
|
case 'visits' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.$result->getVisits().'],'; break;
|
|
|
|
case 'pageviews' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.$result->getPageviews().'],'; break;
|
|
|
|
case 'pageviewspervisit' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", {v:'.$result->getPageviewsPerVisit().', f:\''.round($result->getPageviewsPerVisit(),2).'\'}],'; break;
|
|
|
|
case 'entrancebouncerate' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", {v:'.$result->getEntrancebouncerate().', f:\''.round($result->getEntrancebouncerate(),2).'%\'}],'; break;
|
|
|
|
case 'avgtimeonsite' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", {v:'.$result->getAvgtimeonsite().', f:\''.secondMinute($result->getAvgtimeonsite()).'\'}],'; break;
|
|
|
|
case 'percentnewvisits' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", {v:'.$result->getPercentNewVisits().', f:\''.round($result->getPercentNewVisits(),2).'%\'}],'; break;
|
|
|
|
case 'transactionspervisit' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.round($result->getTransactionsPerVisit(),2).'],'; break;
|
|
|
|
case 'transactions' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.$result->getTransactions().'],'; break;
|
|
|
|
case 'totalvalue' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.round($result->getTotalValue(),2).'],'; break;
|
|
|
|
case 'revenuepertransaction' : foreach($results as $result) $donnees .= '["'.date('M j',strtotime($result->getDate())).'", '.round($result->getRevenuePerTransaction(),2).'],'; break;
|
|
|
|
default : break;
|
|
|
|
}
|
|
|
|
$return = 'google.load("visualization", "1", {packages:["corechart"]});
|
|
|
|
google.setOnLoadCallback(draw'.$id_cible.');
|
|
|
|
function draw'.$id_cible.'(){
|
|
|
|
var data = new google.visualization.DataTable();
|
|
|
|
data.addColumn(\'string\', \'Day\');
|
|
|
|
data.addColumn(\'number\', \''.$columnName.'\');
|
|
|
|
data.addRows(['.$donnees.']);
|
|
|
|
var chart = new google.visualization.AreaChart(document.getElementById(\''.$id_cible.'\'));
|
|
|
|
chart.draw(data, {width: 468, height: 180, title: \''.$date_depart.' - '.$date_fin.'\',
|
|
|
|
colors:[\'#058dc7\',\'#e6f4fa\'],
|
|
|
|
areaOpacity: 0.1,
|
|
|
|
hAxis: {textPosition: \'in\', showTextEvery: 5, slantedText: false, textStyle: { color: \'#058dc7\', fontSize: 10 } },
|
|
|
|
pointSize: 5,
|
|
|
|
legend: \'none\',
|
|
|
|
chartArea:{left:0,top:30,width:"100%",height:"100%"}
|
|
|
|
});
|
|
|
|
}';
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|