-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 70a449d
Showing
13 changed files
with
946 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DON'T BE A DICK PUBLIC LICENSE | ||
|
||
Version 1, December 2009 | ||
|
||
Copyright (C) 2009 Philip Sturgeon [email protected] | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. | ||
|
||
DON'T BE A DICK PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
Do whatever you like with the original work, just don't be a dick. | ||
|
||
Being a dick includes - but is not limited to - the following instances: | ||
|
||
1a. Outright copyright infringement - Don't just copy this and change the name. | ||
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick. | ||
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick. | ||
|
||
If you become rich through modifications, related works/services, or supporting the original work, share the love. Only a dick would make loads off this work and not buy the original works creator(s) a pint. | ||
|
||
Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Composer Library Template | ||
========================= | ||
|
||
If you are trying to create a new PHP Composer library, whether it will be going to submitted to packagist.org or just in your Github account, this template of files will surely help you make the process a lot easier and faster. | ||
|
||
Features | ||
-------- | ||
|
||
* PSR-4 autoloading compliant structure | ||
* Unit-Testing with PHPUnit | ||
* Comprehensive Guides and tutorial | ||
* Easy to use to any framework or even a plain php file | ||
|
||
|
||
I encourage that you put more information on this readme file instead of leaving it as is. See [http://www.darwinbiler.com/designing-and-making-the-readme-file-for-your-github-repository/](How to make a README file) for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "lvengine/analytics", | ||
"description": "Fetch data from GA", | ||
"license": "proprietary", | ||
"authors": [ | ||
{ | ||
"name": "João Serpa | LVEngine", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"type": "project", | ||
"require": { | ||
"php": ">=5.4", | ||
"google/apiclient": "^2.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "5.2.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Analytics\\": "src/Analytics/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
|
||
use \Analytics\Ga; | ||
use \Analytics\Audience; | ||
use \Analytics\Conversion; | ||
use \Analytics\Behavior; | ||
|
||
$audience = new Behavior(); | ||
$audience->setViewId("137104990"); | ||
$audience->setDate("2017-08-01", "2017-08-07"); | ||
|
||
echo "<pre>"; | ||
print_r($audience->internalSearches()); | ||
echo "</pre>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<phpunit bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="true"> | ||
<testsuites> | ||
<testsuite name="Unit Tests"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Analytics; | ||
|
||
/** | ||
* Aquisition | ||
* --- | ||
* This Class access and makes available the | ||
* Aquisition requests. | ||
* | ||
* @author [email protected] | ||
*/ | ||
class Aquisition extends Ga | ||
{ | ||
|
||
// | ||
// ─── PUBLIC METHODS ───────────────────────────────────────────────────────────── | ||
// | ||
public function sessionsByChannel() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions'), | ||
'dimensions' => array('channelGrouping') | ||
) | ||
); | ||
} | ||
public function sessionsBySourcesMediums() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions'), | ||
'dimensions' => array('sourceMedium') | ||
) | ||
); | ||
} | ||
public function campaigns() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('users', 'newUsers', 'sessions', 'bounceRate', 'avgSessionDuration'), | ||
'dimensions' => array('campaign'), | ||
"sorts" => array( | ||
array( | ||
'fieldName' => 'ga:users', | ||
'orderType' => 'VALUE', | ||
'sortOrder' => 'DESCENDING' | ||
) | ||
), | ||
'page_size' => 21 | ||
) | ||
); | ||
} | ||
// ──────────────────────────────────────────────────────────────────────────────── | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Analytics; | ||
|
||
/** | ||
* Audience | ||
* --- | ||
* This Class access and makes available the | ||
* Audience requests. | ||
* | ||
* @author [email protected] | ||
*/ | ||
class Audience extends Ga | ||
{ | ||
|
||
// | ||
// ─── PUBLIC METHODS ───────────────────────────────────────────────────────────── | ||
// | ||
public function sessionsByGender() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions'), | ||
'dimensions' => array('userGender') | ||
) | ||
); | ||
} | ||
public function sessionsByAge() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions'), | ||
'dimensions' => array('userAgeBracket') | ||
) | ||
); | ||
} | ||
public function sessionsByCountry() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions'), | ||
'dimensions' => array('country') | ||
) | ||
); | ||
} | ||
public function sessionsAndUsers() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('sessions', 'users'), | ||
'dimensions' => array('date') | ||
) | ||
); | ||
} | ||
public function bounceRate() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('bounceRate'), | ||
) | ||
); | ||
} | ||
// ──────────────────────────────────────────────────────────────────────────────── | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Analytics; | ||
|
||
/** | ||
* Behavior | ||
* --- | ||
* This Class access and makes available the | ||
* Behavior requests. | ||
* | ||
* @author [email protected] | ||
*/ | ||
class Behavior extends Ga | ||
{ | ||
// | ||
// ─── PUBLIC METHODS ───────────────────────────────────────────────────────────── | ||
// | ||
public function internalSearches() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('searchUniques'), | ||
'dimensions' => array('searchKeyword'), | ||
'sorts' => array( | ||
array( | ||
'fieldName' => 'ga:searchUniques', | ||
'orderType' => 'VALUE', | ||
'sortOrder' => 'DESCENDING' | ||
) | ||
), | ||
"page_size" => 25 | ||
) | ||
); | ||
} | ||
public function internalSearchesWithoutResults() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('totalEvents', 'uniqueEvents'), | ||
'dimensions' => array('eventLabel'), | ||
'sorts' => array( | ||
array( | ||
'fieldName' => 'ga:totalEvents', | ||
'orderType' => 'VALUE', | ||
'sortOrder' => 'DESCENDING' | ||
) | ||
), | ||
'page_size' => 25, | ||
'filters' => 'ga:eventAction==Sem Resultados' | ||
) | ||
); | ||
} | ||
public function eCommerceEvents() | ||
{ | ||
return $this->metricsByDimensions( | ||
array( | ||
'metrics' => array('totalEvents', 'uniqueEvents'), | ||
'dimensions' => array('eventAction'), | ||
'sorts' => array( | ||
array( | ||
'fieldName' => 'ga:totalEvents', | ||
'orderType' => 'VALUE', | ||
'sortOrder' => 'DESCENDING' | ||
) | ||
), | ||
'page_size' => 25, | ||
'filters' => 'ga:eventCategory==eCommerce,ga:eventAction!=Product Impression' | ||
) | ||
); | ||
} | ||
// ──────────────────────────────────────────────────────────────────────────────── | ||
} |
Oops, something went wrong.