diff --git a/modules/gapi/gapi.php b/modules/gapi/gapi.php
index 31e5276a6..75dfceab6 100644
--- a/modules/gapi/gapi.php
+++ b/modules/gapi/gapi.php
@@ -48,6 +48,12 @@ class Gapi extends Module
return $this->api_3_0_getContent();
}
+ public function requestReportData($dimensions, $metrics, $date_from, $date_to, $sort = null, $filters = null, $start = 1, $limit = 30)
+ {
+ // You can switch to the 1.3 API by replacing the following function call by $this->api_1_3_requestReportData()
+ return $this->api_3_0_requestReportData($dimensions, $metrics, $date_from, $date_to, $sort, $filters, $start, $limit);
+ }
+
public function api_3_0_authenticate()
{
// https://developers.google.com/accounts/docs/OAuth2WebServer
@@ -103,7 +109,7 @@ class Gapi extends Module
public function api_3_0_getContent()
{
$html = '';
- if (Tools::isSubmit('PS_GAPI30_CLIENT_ID'))
+ if (Tools::getValue('PS_GAPI30_CLIENT_ID'))
{
Configuration::updateValue('PS_GAPI30_REQUEST_URI_TMP', dirname($_SERVER['REQUEST_URI']).'/'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'));
Configuration::updateValue('PS_GAPI30_CLIENT_ID_TMP', trim(Tools::getValue('PS_GAPI30_CLIENT_ID')));
@@ -124,13 +130,72 @@ class Gapi extends Module
$html .= $this->displayError('Google API Authorization granted but access token cannot be retrieved');
}
+ $display_slider = true;
if (Configuration::get('PS_GAPI30_CLIENT_ID') && Configuration::get('PS_GAPI30_CLIENT_SECRET') && Configuration::get('PS_GAPI30_PROFILE'))
{
$result_test = $this->api_3_0_requestReportData('', 'ga:visits,ga:uniquePageviews', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')), null, null, 1, 1);
if (!$result_test)
$html .= $this->displayError('Cannot retrieve test results');
else
+ {
+ $display_slider = false;
$html .= $this->displayConfirmation(sprintf($this->l('Yesterday, your store received the visit of %d people for a total of %d unique page views.'), $result_test[0]['metrics']['visits'], $result_test[0]['metrics']['uniquePageviews']));
+ }
+ }
+
+ if ($display_slider)
+ {
+ $slides = array(
+ 'Google API - 01 - Start.png' => $this->l('Go to https://code.google.com/apis/console and click the "Create project..." button'),
+ 'Google API - 02 - Services.png' => $this->l('In the "Services" tab, switch on the Analytics API'),
+ 'Google API - 03 - Terms.png' => $this->l('You will be asked to agree to the Terms of Service of Google APIs'),
+ 'Google API - 04 - Terms.png' => $this->l('And the Terms of Service of Analytics API'),
+ 'Google API - 05 - Services OK.png' => $this->l('You should now have something like that'),
+ 'Google API - 06 - API Access.png' => $this->l('In the "API Access" tab, click the big, blue, "Create an OAuth 2.0 client ID..." button'),
+ 'Google API - 07 - Create Client ID.png' => $this->l('Fill in the form with the name of your store, the URL of your logo and the URL of your store then click "Next"'),
+ 'Google API - 08 - Create Client ID.png' => sprintf($this->l('Keep "Web application" select and fill in the "Authorized Redirect URIs" area with the following URL: %s (you may have to click the "more options" link). Then validate by clicking the "Create client ID" button'), Tools::getShopDomain(true, false).__PS_BASE_URI__.'modules/'.$this->name.'/oauth2callback.php'),
+ 'Google API - 09 - API Access created.png' => $this->l('You should now have the following screen. Copy/Paste the "Client ID" and "Client secret" into the form below'),
+ 'Google API - 10 - Profile ID.png' => $this->l('Now you need the ID of the Analytics Profile you want to connect. In order to find you Profile ID, connect to the Analytics dashboard look at the URL in the address bar. Your Profile ID is the number following a "p", as shown underlined in red on the screenshot')
+ );
+ $first_slide = key($slides);
+
+ $html .= '
+
+