Version Notes
Módulo de integração entre o magento e a plataforma RD Station da Resultados Digitais para criação e qualificação de leads.
Este módulo executa chamadas para a API do RDStation quando:
Um formulário de contato é enviado
Uma nova conta de cliente é criada
Um novo pedido é criado
Um cliente assina a newsletter da loja virtual
Download this release
Release Info
Developer | Flow eCommerce |
Extension | flowecommerce_resultadosdigitais |
Version | 0.1.1 |
Comparing to | |
See all releases |
Version 0.1.1
- app/code/local/Flowecommerce/Resultadosdigitais/Helper/Data.php +17 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Api.php +104 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Customvar.php +79 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Tracker.php +329 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/A.php +183 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/B.php +110 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/C.php +66 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/V.php +74 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/Z.php +265 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Observer.php +158 -0
- app/code/local/Flowecommerce/Resultadosdigitais/Model/Requestdata.php +5 -0
- app/code/local/Flowecommerce/Resultadosdigitais/etc/adminhtml.xml +23 -0
- app/code/local/Flowecommerce/Resultadosdigitais/etc/config.xml +71 -0
- app/code/local/Flowecommerce/Resultadosdigitais/etc/system.xml +56 -0
- app/etc/modules/Flowecommerce_Resultadosdigitais.xml +9 -0
- package.xml +32 -0
app/code/local/Flowecommerce/Resultadosdigitais/Helper/Data.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Flowecommerce_Resultadosdigitais_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getToken() {
|
6 |
+
return Mage::getStoreConfig('resultadosdigitais/general/token');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getPrivateToken() {
|
10 |
+
return Mage::getStoreConfig('resultadosdigitais/general/private_token');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function isEnabled() {
|
14 |
+
return Mage::getStoreConfigFlag('resultadosdigitais/general/enable');
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Api.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Flowecommerce_Resultadosdigitais_Model_Api
|
4 |
+
{
|
5 |
+
|
6 |
+
const API_URL_CONVERSIONS = 'https://www.rdstation.com.br/api/1.2/conversions/';
|
7 |
+
const API_URL_SERVICES = 'https://www.rdstation.com.br/api/1.2/services/';
|
8 |
+
|
9 |
+
protected $_helper = null;
|
10 |
+
protected $_httpClient = null;
|
11 |
+
|
12 |
+
public function markSale($email, $value)
|
13 |
+
{
|
14 |
+
try {
|
15 |
+
$data = array(
|
16 |
+
'status' => 'won',
|
17 |
+
'value' => $value,
|
18 |
+
'email' => $email,
|
19 |
+
);
|
20 |
+
$token = $this->_getHelper()->getPrivateToken();
|
21 |
+
$url = API_URL_SERVICES . "{$token}/generic";
|
22 |
+
$leadHttpClient = $this->_getHttpClient();
|
23 |
+
$leadHttpClient
|
24 |
+
->resetParameters()
|
25 |
+
->setUri($url)
|
26 |
+
->setMethod(Zend_Http_Client::POST)
|
27 |
+
->setParameterPost($data);
|
28 |
+
$response = $leadHttpClient->request();
|
29 |
+
$responseBody = $response->getBody();
|
30 |
+
} catch (Exception $e) {
|
31 |
+
Mage::logException($e);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function addLeadConversion($conversionIdentifier, Flowecommerce_Resultadosdigitais_Model_Requestdata $data)
|
36 |
+
{
|
37 |
+
try {
|
38 |
+
if ($this->validateLead($conversionIdentifier, $data)) {
|
39 |
+
$data_query = http_build_query($data);
|
40 |
+
|
41 |
+
# Refactor para utilizar zend_http_client
|
42 |
+
# Lembrar de parâmetros que estavam sendo setados de maneira tosquíssima
|
43 |
+
$leadHttpClient = $this->_getHttpClient();
|
44 |
+
$leadHttpClient
|
45 |
+
->resetParameters()
|
46 |
+
->setUri(self::API_URL_CONVERSIONS)
|
47 |
+
->setMethod(Zend_Http_Client::POST)
|
48 |
+
->setParameterPost($this->_prepareParams($conversionIdentifier, $data));
|
49 |
+
|
50 |
+
$response = $leadHttpClient->request();
|
51 |
+
$responseBody = $response->getBody();
|
52 |
+
}
|
53 |
+
} catch (Exception $e) {
|
54 |
+
Mage::logException($e);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _getHelper() {
|
59 |
+
if (is_null($this->_helper)) {
|
60 |
+
$this->_helper = Mage::helper('resultadosdigitais');
|
61 |
+
}
|
62 |
+
return $this->_helper;
|
63 |
+
}
|
64 |
+
|
65 |
+
protected function _getHttpClient() {
|
66 |
+
if (!$this->_httpClient instanceof Varien_Http_Client) {
|
67 |
+
$this->_httpClient = new Varien_Http_Client();
|
68 |
+
}
|
69 |
+
return $this->_httpClient;
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function _prepareParams($conversionIdentifier, Flowecommerce_Resultadosdigitais_Model_Requestdata $data) {
|
73 |
+
$return = array();
|
74 |
+
|
75 |
+
# formatando valores da requisição
|
76 |
+
foreach ($data->getData() as $key => $value) {
|
77 |
+
$return[$key] = $value;
|
78 |
+
}
|
79 |
+
|
80 |
+
# valores adicionais, adicionaidos por último para garantir que não são sobrescritos pelo que for enviado à API
|
81 |
+
$return['token_rdstation'] = $this->_getHelper()->getToken();
|
82 |
+
$return['identificador'] = $conversionIdentifier;
|
83 |
+
|
84 |
+
# Utmz
|
85 |
+
$tracker = Mage::getModel('resultadosdigitais/googleanalytics_tracker');
|
86 |
+
if ($utmz = $tracker->getUtmZString()) {
|
87 |
+
$return['c_utmz'] = $utmz;
|
88 |
+
}
|
89 |
+
|
90 |
+
return $return;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function validateLead($conversionIdentifier, Flowecommerce_Resultadosdigitais_Model_Requestdata $data) {
|
94 |
+
$return = true;
|
95 |
+
|
96 |
+
# Verificando existência de parâmetros obrigatórios
|
97 |
+
$token = $this->_getHelper()->getToken();
|
98 |
+
if (!$token || !$conversionIdentifier || !$data->getEmail()) {
|
99 |
+
$return = false;
|
100 |
+
}
|
101 |
+
|
102 |
+
return $return;
|
103 |
+
}
|
104 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Customvar.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Customvar {
|
5 |
+
|
6 |
+
/**
|
7 |
+
* The Slot Number. An integer between 1 and 5.
|
8 |
+
*/
|
9 |
+
private $slot_number;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* The name of the variable. This appears in the top-level Custom Variables report of the Analytics reports.
|
13 |
+
*/
|
14 |
+
private $name;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Value
|
18 |
+
*/
|
19 |
+
private $value;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* 1 (visitor-level), 2 (session-level), or 3 (page-level)
|
23 |
+
*
|
24 |
+
* Only variables set for scope 1 will result in a cookie being set.
|
25 |
+
*/
|
26 |
+
private $scope;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param array $v - Array containing parsed __utmv Customvar information.
|
30 |
+
*/
|
31 |
+
public function __construct($v) {
|
32 |
+
if(is_array($v))
|
33 |
+
$this->fromArray($v);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function fromArray(array $v_arr) {
|
37 |
+
if (array_key_exists(0, $v_arr))
|
38 |
+
$this->setSlotNumber($v_arr[0]);
|
39 |
+
if (array_key_exists(1, $v_arr))
|
40 |
+
$this->setName($v_arr[1]);
|
41 |
+
if (array_key_exists(2, $v_arr))
|
42 |
+
$this->setValue($v_arr[2]);
|
43 |
+
if (array_key_exists(3, $v_arr))
|
44 |
+
$this->setScope($v_arr[3]);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function setSlotNumber($slot_number) {
|
48 |
+
$this->slot_number = $slot_number;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getSlotNumber() {
|
52 |
+
return $this->slot_number;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function setName($name) {
|
56 |
+
$this->name = $name;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getName() {
|
60 |
+
return $this->name;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function setValue($value) {
|
64 |
+
$this->value = $value;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getValue() {
|
68 |
+
return $this->value;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function setScope($scope) {
|
72 |
+
$this->scope = $scope;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getScope() {
|
76 |
+
return $this->scope;
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Tracker.php
ADDED
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class presents a unified interface to all of the UTM cookies.
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Tracker {
|
8 |
+
|
9 |
+
private $utma;
|
10 |
+
|
11 |
+
private $utmb;
|
12 |
+
|
13 |
+
private $utmc;
|
14 |
+
|
15 |
+
private $utmv;
|
16 |
+
|
17 |
+
private $utmz;
|
18 |
+
private $utmzstring;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The constructor takes either:
|
22 |
+
*
|
23 |
+
* a) $_COOKIE - Normal usage. The cookie superglobal contains the cookies
|
24 |
+
* set by Google Analytics.
|
25 |
+
*
|
26 |
+
* b) $_REQUEST ($_GET) - If _getLinkerUrl() is used, the UTM cookies will
|
27 |
+
* embedded in the query string.
|
28 |
+
*
|
29 |
+
* @param array $utm Array of UTM parameters (__utm[a, b, c, z and maybe v)
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
$utm = $_COOKIE;
|
33 |
+
if(array_key_exists('__utma', $utm))
|
34 |
+
$this->parseUtmA($utm['__utma']);
|
35 |
+
|
36 |
+
if(array_key_exists('__utmb', $utm))
|
37 |
+
$this->parseUtmB($utm['__utmb']);
|
38 |
+
|
39 |
+
if(array_key_exists('__utmc', $utm))
|
40 |
+
$this->parseUtmC($utm['__utmc']);
|
41 |
+
|
42 |
+
if(array_key_exists('__utmv', $utm))
|
43 |
+
$this->parseUtmV($utm['__utmv']);
|
44 |
+
|
45 |
+
if(array_key_exists('__utmz', $utm))
|
46 |
+
$this->parseUtmZ($utm['__utmz']);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_A $utma
|
51 |
+
*/
|
52 |
+
public function setUtmA(Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_A $utma = null) {
|
53 |
+
$this->utma = $utma;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @return Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_A $utma
|
58 |
+
*/
|
59 |
+
public function getUtmA() {
|
60 |
+
return $this->utma;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The string as it appears in the cookie.
|
65 |
+
*
|
66 |
+
* @param string $__utma
|
67 |
+
*/
|
68 |
+
public function parseUtmA($__utma) {
|
69 |
+
$this->setUtmA(Mage::getModel('resultadosdigitais/googleanalytics_utm_a',$__utma));
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_B $utmb
|
74 |
+
*/
|
75 |
+
public function setUtmB(Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_B $utmb = null) {
|
76 |
+
$this->utmb = $utmb;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_B $utmb
|
81 |
+
*/
|
82 |
+
public function getUtmB() {
|
83 |
+
return $this->utmb;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* The string as it appears in the cookie.
|
88 |
+
*
|
89 |
+
* @param string $__utmb
|
90 |
+
*/
|
91 |
+
public function parseUtmB($__utmb) {
|
92 |
+
$this->setUtmB(Mage::getModel('resultadosdigitais/googleanalytics_utm_b', $__utmb));
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @param Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_C $utmc
|
97 |
+
*/
|
98 |
+
public function setUtmC(Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_C $utmc) {
|
99 |
+
$this->utmc = $utmc;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @return Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_C $utmc
|
104 |
+
*/
|
105 |
+
public function getUtmC() {
|
106 |
+
return $this->utmc;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* The string as it appears in the cookie.
|
111 |
+
*
|
112 |
+
* @param string $__utmc
|
113 |
+
*/
|
114 |
+
public function parseUtmC($__utmc) {
|
115 |
+
$this->setUtmC(Mage::getModel('resultadosdigitais/googleanalytics_utm_c', $__utmc));
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @param Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_V $utmv
|
120 |
+
*/
|
121 |
+
public function setUtmV(Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_V $utmv) {
|
122 |
+
$this->utmv = $utmv;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @return Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_V $utmv
|
127 |
+
*/
|
128 |
+
public function getUtmV() {
|
129 |
+
return $this->utmv;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* The string as it appears in the cookie.
|
134 |
+
*
|
135 |
+
* @param string $__utmv
|
136 |
+
*/
|
137 |
+
public function parseUtmV($__utmv) {
|
138 |
+
$this->setUtmV(Mage::getModel('resultadosdigitais/googleanalytics_utm_v', $__utmv));
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @param Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_Z $utmz
|
143 |
+
*/
|
144 |
+
public function setUtmZ(Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_Z $utmz) {
|
145 |
+
$this->utmz = $utmz;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @return Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_Z $utmz
|
150 |
+
*/
|
151 |
+
public function getUtmZ() {
|
152 |
+
return $this->utmz;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @return string $utmz
|
157 |
+
*/
|
158 |
+
public function getUtmZString() {
|
159 |
+
return $this->utmzstring;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* The string as it appears in the cookie.
|
164 |
+
*
|
165 |
+
* @param string $__utmz
|
166 |
+
*/
|
167 |
+
public function parseUtmZ($__utmz) {
|
168 |
+
$this->setUtmZ(Mage::getModel('resultadosdigitais/googleanalytics_utm_z', $__utmz));
|
169 |
+
$this->utmzstring = $__utmz;
|
170 |
+
}
|
171 |
+
|
172 |
+
// BEGIN Accessor Functions for UTMs
|
173 |
+
private function _isValid($obj) {
|
174 |
+
return $obj && $obj->isValid();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* The domain hash allows you to track multiple
|
179 |
+
* subdomains with the same tracking code.
|
180 |
+
*
|
181 |
+
* @return string $domain_hash
|
182 |
+
*/
|
183 |
+
public function getDomainHash() {
|
184 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getDomainHash() : null;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* @return string Visitor ID assigned by the good folks at Google.
|
189 |
+
*/
|
190 |
+
public function getVisitorId() {
|
191 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getVisitorId() : null;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* DateTime object representing the initial visit.
|
196 |
+
*
|
197 |
+
* @return \DateTime $initial_visit.
|
198 |
+
*/
|
199 |
+
public function getInitialVisit() {
|
200 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getInitialVisit() : null;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* DateTime object representing the previous visit.
|
205 |
+
*
|
206 |
+
* @return \DateTime $previous_visit.
|
207 |
+
*/
|
208 |
+
public function getPreviousVisit() {
|
209 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getPreviousVisit() : null;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* DateTime object representing the current visit start.
|
214 |
+
*
|
215 |
+
* @return \DateTime $current_visit_start.
|
216 |
+
*/
|
217 |
+
public function getCurrentVisit() {
|
218 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getCurrentVisit() : null;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* The number of times that the user has left and returned.
|
223 |
+
*
|
224 |
+
* This means the user either closed the browser or was
|
225 |
+
* inactive on this site for 30mins or more.
|
226 |
+
*
|
227 |
+
* @return int $session_count
|
228 |
+
*/
|
229 |
+
public function getSessionCount() {
|
230 |
+
return $this->_isValid($this->getUtmA()) ? $this->getUtmA()->getSessionCount() : null;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* @return int $pages_viewed
|
235 |
+
*/
|
236 |
+
public function getPagesViewed() {
|
237 |
+
return $this->_isValid($this->getUtmB()) ? $this->getUtmB()->getPagesViewed() : null;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* @return \DateTime $current_session_start
|
242 |
+
*/
|
243 |
+
public function getCurrentSessionStart() {
|
244 |
+
return $this->_isValid($this->getUtmB()) ? $this->getUtmB()->getCurrentSessionStart() : null;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Returns an array<GoogleAnalytics\CampaignTracking\Customvar> of custom
|
249 |
+
* variables stored in the __utmv cookie.
|
250 |
+
*
|
251 |
+
* @return array $custom_vars
|
252 |
+
*/
|
253 |
+
public function getCustomvars() {
|
254 |
+
return $this->_isValid($this->getUtmV()) ? $this->getUtmV()->getCustomvars() : array();
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Timestamp recorded in __utmz
|
259 |
+
*
|
260 |
+
* @return \DateTime $datetime
|
261 |
+
*/
|
262 |
+
public function getDateTime() {
|
263 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getDateTime() : null;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Session Number as recorded in __utmz
|
268 |
+
*
|
269 |
+
* @return int $session_number
|
270 |
+
*/
|
271 |
+
public function getSessionNumber() {
|
272 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getSessionNumber() : null;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Number of campaigns that have driven this visitor here.
|
277 |
+
*
|
278 |
+
* @return int $campaign_number
|
279 |
+
*/
|
280 |
+
public function getCampaignNumber() {
|
281 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignNumber() : null;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* @return string $campaign_source
|
286 |
+
*/
|
287 |
+
public function getCampaignSource() {
|
288 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignSource() : null;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* @return string $campaign_medium
|
293 |
+
*/
|
294 |
+
public function getCampaignMedium() {
|
295 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignMedium() : null;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @return string $campaign_name
|
300 |
+
*/
|
301 |
+
public function getCampaignName() {
|
302 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignName() : null;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
*
|
307 |
+
*/
|
308 |
+
public function getCampaignContent() {
|
309 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignContent() : null;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Space delimited list of keywords.
|
314 |
+
*
|
315 |
+
* @return string $campaign_term
|
316 |
+
*/
|
317 |
+
public function getCampaignTerm() {
|
318 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getCampaignTerm() : null;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Array of strings of keywords derived from $campaign_term.
|
323 |
+
*
|
324 |
+
* @return array $keywords
|
325 |
+
*/
|
326 |
+
public function getKeywords() {
|
327 |
+
return $this->_isValid($this->getUtmZ()) ? $this->getUtmZ()->getKeywords() : array();
|
328 |
+
}
|
329 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/A.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class represents the __utma cookie.
|
5 |
+
*
|
6 |
+
* Description from Google(r):
|
7 |
+
*
|
8 |
+
* This cookie is typically written to the browser upon the first visit to your
|
9 |
+
* site from that web browser. If the cookie has been deleted by the browser
|
10 |
+
* operator, and the browser subsequently visits your site, a new __utma cookie
|
11 |
+
* is written with a different unique ID. In most cases, this cookie is used to
|
12 |
+
* determine unique visitors to your site and it is updated with each page view.
|
13 |
+
* Additionally, this cookie is provided with a unique ID that Google Analytics
|
14 |
+
* uses to ensure both the validity and accessibility of the cookie as an extra
|
15 |
+
* security measure.
|
16 |
+
*/
|
17 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_A {
|
18 |
+
|
19 |
+
private $domain_hash;
|
20 |
+
|
21 |
+
private $visitor_id;
|
22 |
+
|
23 |
+
private $initial_visit;
|
24 |
+
|
25 |
+
private $previous_visit;
|
26 |
+
|
27 |
+
private $current_visit;
|
28 |
+
|
29 |
+
private $session_count;
|
30 |
+
|
31 |
+
private $is_valid;
|
32 |
+
|
33 |
+
public function __construct($__utma = null) {
|
34 |
+
$this->is_valid = false;
|
35 |
+
$this->parse($__utma);
|
36 |
+
}
|
37 |
+
|
38 |
+
public function isValid() {
|
39 |
+
return $this->is_valid;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function parse($__utma) {
|
43 |
+
if($__utma == null)
|
44 |
+
return;
|
45 |
+
|
46 |
+
if(!$this->validate($__utma))
|
47 |
+
return;
|
48 |
+
|
49 |
+
$this->is_valid = true;
|
50 |
+
|
51 |
+
list($domain_hash, $visitor_id, $initial_visit, $previous_visit, $current_visit, $session_count) = preg_split('[\.]', $__utma);
|
52 |
+
|
53 |
+
$this->setDomainHash($domain_hash);
|
54 |
+
$this->setVisitorId($visitor_id);
|
55 |
+
|
56 |
+
$this->setInitialVisit(new \DateTime());
|
57 |
+
$this->getInitialVisit()->setTimestamp($initial_visit);
|
58 |
+
|
59 |
+
$this->setPreviousVisit(new \DateTime());
|
60 |
+
$this->getPreviousVisit()->setTimestamp($previous_visit);
|
61 |
+
|
62 |
+
$this->setCurrentVisit(new \DateTime());
|
63 |
+
$this->getCurrentVisit()->setTimestamp($current_visit);
|
64 |
+
|
65 |
+
$this->setSessionCount($session_count);
|
66 |
+
}
|
67 |
+
|
68 |
+
private function validate($__utma) {
|
69 |
+
return preg_match('/^\d+\.\d+\.\d+\.\d+\.\d+/', $__utma);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* The domain hash allows you to track multiple
|
74 |
+
* subdomains with the same tracking code.
|
75 |
+
*
|
76 |
+
* @param string $domain_hash
|
77 |
+
*/
|
78 |
+
public function setDomainHash($domain_hash) {
|
79 |
+
$this->domain_hash = $domain_hash;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* The domain hash allows you to track multiple
|
84 |
+
* subdomains with the same tracking code.
|
85 |
+
*
|
86 |
+
* @return string $domain_hash
|
87 |
+
*/
|
88 |
+
public function getDomainHash() {
|
89 |
+
return $this->domain_hash;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param string Visitor ID assigned by the good folks at Google.
|
94 |
+
*/
|
95 |
+
public function setVisitorId($visitor_id) {
|
96 |
+
$this->visitor_id = $visitor_id;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @return string Visitor ID assigned by the good folks at Google.
|
101 |
+
*/
|
102 |
+
public function getVisitorId() {
|
103 |
+
return $this->visitor_id;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* DateTime object representing the initial visit.
|
108 |
+
*
|
109 |
+
* @param \DateTime $initial_visit.
|
110 |
+
*/
|
111 |
+
public function setInitialVisit(\DateTime $initial_visit = null) {
|
112 |
+
$this->initial_visit = $initial_visit;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* DateTime object representing the initial visit.
|
117 |
+
*
|
118 |
+
* @return \DateTime $initial_visit.
|
119 |
+
*/
|
120 |
+
public function getInitialVisit() {
|
121 |
+
return $this->initial_visit;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* DateTime object representing the previous visit.
|
126 |
+
*
|
127 |
+
* @return \DateTime $previous_visit.
|
128 |
+
*/
|
129 |
+
public function setPreviousVisit(\DateTime $previous_visit = null) {
|
130 |
+
$this->previous_visit = $previous_visit;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* DateTime object representing the previous visit.
|
135 |
+
*
|
136 |
+
* @return \DateTime $previous_visit.
|
137 |
+
*/
|
138 |
+
public function getPreviousVisit() {
|
139 |
+
return $this->previous_visit;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* DateTime object representing the current visit start.
|
144 |
+
*
|
145 |
+
* @param \DateTime $current_visit_start.
|
146 |
+
*/
|
147 |
+
public function setCurrentVisit(\DateTime $current_visit = null) {
|
148 |
+
$this->current_visit = $current_visit;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* DateTime object representing the current visit start.
|
153 |
+
*
|
154 |
+
* @return \DateTime $current_visit_start.
|
155 |
+
*/
|
156 |
+
public function getCurrentVisit() {
|
157 |
+
return $this->current_visit;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* The number of times that the user has left and returned.
|
162 |
+
*
|
163 |
+
* This means the user either closed the browser or was
|
164 |
+
* inactive on this site for 30mins or more.
|
165 |
+
*
|
166 |
+
* @param int $session_count
|
167 |
+
*/
|
168 |
+
public function setSessionCount($session_count) {
|
169 |
+
$this->session_count = $session_count;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* The number of times that the user has left and returned.
|
174 |
+
*
|
175 |
+
* This means the user either closed the browser or was
|
176 |
+
* inactive on this site for 30mins or more.
|
177 |
+
*
|
178 |
+
* @return int $session_count
|
179 |
+
*/
|
180 |
+
public function getSessionCount() {
|
181 |
+
return $this->session_count;
|
182 |
+
}
|
183 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/B.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class represents the __utmb cookie.
|
5 |
+
*
|
6 |
+
* Description from Google(r):
|
7 |
+
*
|
8 |
+
* This cookie is used to establish and continue a user session with your site.
|
9 |
+
* When a user views a page on your site, the Google Analytics code attempts
|
10 |
+
* to update this cookie. If it does not find the cookie, a new one is written
|
11 |
+
* and a new session is established. Each time a user visits a different page
|
12 |
+
* on your site, this cookie is updated to expire in 30 minutes, thus
|
13 |
+
* continuing a single session for as long as user activity continues within
|
14 |
+
* 30-minute intervals. This cookie expires when a user pauses on a page on
|
15 |
+
* your site for longer than 30 minutes. You can modify the default length of a
|
16 |
+
* user session with the _setSessionCookieTimeout() method.
|
17 |
+
*/
|
18 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_B {
|
19 |
+
|
20 |
+
private $domain_hash;
|
21 |
+
|
22 |
+
private $pages_viewed;
|
23 |
+
|
24 |
+
//TODO Need something better here
|
25 |
+
private $garbage;
|
26 |
+
|
27 |
+
private $current_session_start;
|
28 |
+
|
29 |
+
private $is_valid;
|
30 |
+
|
31 |
+
public function __construct($__utmb = null) {
|
32 |
+
$this->is_valid = false;
|
33 |
+
$this->parse($__utmb);
|
34 |
+
}
|
35 |
+
|
36 |
+
public function parse($__utmb) {
|
37 |
+
if($__utmb == null || empty($__utmb))
|
38 |
+
return;
|
39 |
+
|
40 |
+
if(!$this->validate($__utmb))
|
41 |
+
return;
|
42 |
+
|
43 |
+
$this->is_valid = true;
|
44 |
+
|
45 |
+
list($domain_hash,$pages_viewed,$garbage,$current_session_start) = preg_split('[\.]', $__utmb);
|
46 |
+
|
47 |
+
$this->setDomainHash($domain_hash);
|
48 |
+
|
49 |
+
$this->setPagesViewed($pages_viewed);
|
50 |
+
|
51 |
+
$this->setCurrentSessionStart(new \DateTime());
|
52 |
+
$this->getCurrentSessionStart()->setTimestamp($current_session_start);
|
53 |
+
}
|
54 |
+
|
55 |
+
public function isValid() {
|
56 |
+
return $this->is_valid;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function validate($__utmb) {
|
60 |
+
return preg_match('/^\d+\.\d+\.\d+\.\d+/', $__utmb);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The domain hash allows you to track multiple
|
65 |
+
* subdomains with the same tracking code.
|
66 |
+
*
|
67 |
+
* @param string $domain_hash
|
68 |
+
*/
|
69 |
+
public function setDomainHash($domain_hash) {
|
70 |
+
$this->domain_hash = $domain_hash;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* The domain hash allows you to track multiple
|
75 |
+
* subdomains with the same tracking code.
|
76 |
+
*
|
77 |
+
* @return string $domain_hash
|
78 |
+
*/
|
79 |
+
public function getDomainHash() {
|
80 |
+
return $this->domain_hash;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param int $pages_viewed
|
85 |
+
*/
|
86 |
+
public function setPagesViewed($pages_viewed) {
|
87 |
+
$this->pages_viewed = $pages_viewed;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return int $pages_viewed
|
92 |
+
*/
|
93 |
+
public function getPagesViewed() {
|
94 |
+
return $this->pages_viewed;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @param \DateTime $current_session_start
|
99 |
+
*/
|
100 |
+
public function setCurrentSessionStart(\DateTime $current_session_start) {
|
101 |
+
$this->current_session_start = $current_session_start;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return \DateTime $current_session_start
|
106 |
+
*/
|
107 |
+
public function getCurrentSessionStart() {
|
108 |
+
return $this->current_session_start;
|
109 |
+
}
|
110 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/C.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class represents the __utmc cookie.
|
5 |
+
*
|
6 |
+
* Description from Google(r):
|
7 |
+
*
|
8 |
+
* This cookie is no longer used by the ga.js tracking code to determine
|
9 |
+
* session status.
|
10 |
+
*
|
11 |
+
* Historically, this cookie operated in conjunction with the __utmb cookie to
|
12 |
+
* determine whether or not to establish a new session for the user. For
|
13 |
+
* backwards compatibility purposes with sites still using the urchin.js
|
14 |
+
* tracking code, this cookie will continue to be written and will expire when
|
15 |
+
* the user exits the browser. However, if you are debugging your site tracking
|
16 |
+
* and you use the ga.js tracking code, you should not interpret the existence
|
17 |
+
* of this cookie in relation to a new or expired session.
|
18 |
+
*/
|
19 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_C {
|
20 |
+
|
21 |
+
private $domain_hash;
|
22 |
+
|
23 |
+
private $is_valid;
|
24 |
+
|
25 |
+
public function __construct($__utmc) {
|
26 |
+
$this->is_valid = false;
|
27 |
+
$this->parse($__utmc);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function parse($__utmc) {
|
31 |
+
if(!$this->validate($__utmc))
|
32 |
+
return;
|
33 |
+
|
34 |
+
$this->is_valid = true;
|
35 |
+
|
36 |
+
$this->setDomainHash($__utmc);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function isValid() {
|
40 |
+
return $this->is_valid;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function validate($__utmc) {
|
44 |
+
return preg_match('/\d+/', $__utmc);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* The domain hash allows you to track multiple
|
49 |
+
* subdomains with the same tracking code.
|
50 |
+
*
|
51 |
+
* @return string $domain_hash
|
52 |
+
*/
|
53 |
+
public function setDomainHash($domain_hash) {
|
54 |
+
$this->domain_hash = $domain_hash;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* The domain hash allows you to track multiple
|
59 |
+
* subdomains with the same tracking code.
|
60 |
+
*
|
61 |
+
* @param string $domain_hash
|
62 |
+
*/
|
63 |
+
public function getDomainHash() {
|
64 |
+
return $this->domain_hash;
|
65 |
+
}
|
66 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/V.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class represents the __utmv cookie.
|
5 |
+
*
|
6 |
+
* The __utmv cookie stores Customvars.
|
7 |
+
*/
|
8 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_V {
|
9 |
+
|
10 |
+
private $domain_hash;
|
11 |
+
|
12 |
+
private $custom_vars;
|
13 |
+
|
14 |
+
private $is_valid;
|
15 |
+
|
16 |
+
public function __construct($__utmv) {
|
17 |
+
$this->is_valid = false;
|
18 |
+
$this->parse($__utmv);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function parse($__utmv) {
|
22 |
+
$this->custom_vars = array();
|
23 |
+
|
24 |
+
if(!$this->validate($__utmv))
|
25 |
+
return;
|
26 |
+
|
27 |
+
$this->is_valid = true;
|
28 |
+
|
29 |
+
list($this->domain_hash, $custom_var_string) = preg_split('[\|]', $__utmv);
|
30 |
+
|
31 |
+
$custom_vars = array_map(function($v) { return preg_split('[\=]', $v); }, preg_split('[\^]', $custom_var_string));
|
32 |
+
|
33 |
+
foreach($custom_vars as $custom_var) {
|
34 |
+
$this->custom_vars[] = Mage::getModel('resultadosdigitais/googleanalytics_customvar', array('custom_var', $custom_var));
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
public function isValid() {
|
40 |
+
return $this->isValid();
|
41 |
+
}
|
42 |
+
|
43 |
+
public function validate($__utmv) {
|
44 |
+
return preg_match('/^\d+\.\|+(\d=\S+=\S+=\d\^*)/', $__utmv);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* The domain hash allows you to track multiple
|
49 |
+
* subdomains with the same tracking code.
|
50 |
+
*
|
51 |
+
* @param string $domain_hash
|
52 |
+
*/
|
53 |
+
public function setDomainHash($domain_hash) {
|
54 |
+
$this->domain_hash = $domain_hash;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* The domain hash allows you to track multiple
|
59 |
+
* subdomains with the same tracking code.
|
60 |
+
*
|
61 |
+
* @return string $domain_hash
|
62 |
+
*/
|
63 |
+
public function getDomainHash() {
|
64 |
+
return $this->domain_hash;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return array $custom_vars
|
69 |
+
*/
|
70 |
+
public function getCustomvars() {
|
71 |
+
return $this->custom_vars;
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Googleanalytics/Utm/Z.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class represents the __utmz cookie.
|
5 |
+
*
|
6 |
+
* Description from Google(r):
|
7 |
+
*
|
8 |
+
* This cookie stores the type of referral used by the visitor to reach your
|
9 |
+
* site, whether via a direct method, a referring link, a website search, or a
|
10 |
+
* campaign such as an ad or an email link. It is used to calculate search
|
11 |
+
* engine traffic, ad campaigns and page navigation within your own site.
|
12 |
+
* The cookie is updated with each page view to your site.
|
13 |
+
*/
|
14 |
+
class Flowecommerce_Resultadosdigitais_Model_Googleanalytics_Utm_Z {
|
15 |
+
|
16 |
+
private $domain_hash;
|
17 |
+
|
18 |
+
private $datetime;
|
19 |
+
|
20 |
+
private $session_number;
|
21 |
+
|
22 |
+
private $campaign_number;
|
23 |
+
|
24 |
+
// Fields from campaign_data
|
25 |
+
private $campaign_source;
|
26 |
+
|
27 |
+
private $campaign_name;
|
28 |
+
|
29 |
+
private $campaign_medium;
|
30 |
+
|
31 |
+
private $campaign_term;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param $keywords
|
35 |
+
*
|
36 |
+
* An array<string> of keywords derived from $campaign_term.
|
37 |
+
*/
|
38 |
+
private $keywords;
|
39 |
+
|
40 |
+
private $campaign_content;
|
41 |
+
|
42 |
+
private $gclid;
|
43 |
+
|
44 |
+
private $is_valid;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param string $__utmz
|
48 |
+
*/
|
49 |
+
public function __construct($__utmz) {
|
50 |
+
$this->parse($__utmz);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function isValid() {
|
54 |
+
return $this->is_valid;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function validate($__utmz) {
|
58 |
+
return preg_match('/^\d+\.\d+\.\d+\.\d+\./', $__utmz);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param string $__utmz
|
63 |
+
*/
|
64 |
+
public function parse($__utmz) {
|
65 |
+
$this->is_valid = false;
|
66 |
+
|
67 |
+
if(!$this->validate($__utmz))
|
68 |
+
return;
|
69 |
+
|
70 |
+
$this->is_valid = true;
|
71 |
+
|
72 |
+
list($domain_hash,$timestamp, $session_number, $campaign_number, $campaign_data_string) = preg_split('[\.]', $__utmz,5);
|
73 |
+
|
74 |
+
$this->setDomainhash($domain_hash);
|
75 |
+
|
76 |
+
$this->setDateTime(new \DateTime());
|
77 |
+
$this->getDateTime()->setTimestamp($timestamp);
|
78 |
+
|
79 |
+
$this->setSessionNumber($session_number);
|
80 |
+
|
81 |
+
$this->setCampaignNumber($campaign_number);
|
82 |
+
|
83 |
+
// Parse the campaign data
|
84 |
+
$campaign_data = array();
|
85 |
+
parse_str(strtr($campaign_data_string, "|", "&"), $campaign_data);
|
86 |
+
|
87 |
+
if(array_key_exists('utmcsr', $campaign_data))
|
88 |
+
$this->setCampaignSource($campaign_data['utmcsr']);
|
89 |
+
|
90 |
+
if(array_key_exists('utmccn', $campaign_data))
|
91 |
+
$this->setCampaignName($campaign_data['utmccn']);
|
92 |
+
|
93 |
+
if(array_key_exists('utmcmd', $campaign_data))
|
94 |
+
$this->setCampaignMedium($campaign_data['utmcmd']);
|
95 |
+
|
96 |
+
if(array_key_exists('utmctr', $campaign_data) && !empty($campaign_data['utmctr'])) {
|
97 |
+
$this->setCampaignTerm($campaign_data['utmctr']);
|
98 |
+
|
99 |
+
$keywords = explode(' ', $this->getCampaignTerm());
|
100 |
+
|
101 |
+
if(count($keywords) > 0)
|
102 |
+
$this->setKeywords($keywords);
|
103 |
+
}
|
104 |
+
|
105 |
+
if(array_key_exists('utmcct', $campaign_data))
|
106 |
+
$this->setCampaignContent($campaign_data['utmcct']);
|
107 |
+
|
108 |
+
if(array_key_exists('gclid', $campaign_data))
|
109 |
+
$this->setGoogleClickId($campaign_data['gclid']);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* The domain hash allows you to track multiple
|
114 |
+
* subdomains with the same tracking code.
|
115 |
+
*
|
116 |
+
* @param string $domain_hash
|
117 |
+
*/
|
118 |
+
public function setDomainHash($domain_hash) {
|
119 |
+
$this->domain_hash = $domain_hash;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* The domain hash allows you to track multiple
|
124 |
+
* subdomains with the same tracking code.
|
125 |
+
*
|
126 |
+
* @return string $domain_hash
|
127 |
+
*/
|
128 |
+
public function getDomainHash() {
|
129 |
+
return $this->domain_hash;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param \DateTime $datetime
|
134 |
+
*/
|
135 |
+
public function setDateTime(\DateTime $datetime = null) {
|
136 |
+
$this->datetime = $datetime;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @return \DateTime $datetime
|
141 |
+
*/
|
142 |
+
public function getDateTime() {
|
143 |
+
return $this->datetime;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param int $session_number
|
148 |
+
*/
|
149 |
+
public function setSessionNumber($session_number) {
|
150 |
+
$this->session_number = $session_number;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @return int $session_number
|
155 |
+
*/
|
156 |
+
public function getSessionNumber() {
|
157 |
+
return $this->session_number;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @param int $campaign_number
|
162 |
+
*/
|
163 |
+
public function setCampaignNumber($campaign_number) {
|
164 |
+
$this->campaign_number = $campaign_number;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @return int $campaign_number
|
169 |
+
*/
|
170 |
+
public function getCampaignNumber() {
|
171 |
+
return $this->campaign_number;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @param string $campaign_source
|
176 |
+
*/
|
177 |
+
public function setCampaignSource($campaign_source) {
|
178 |
+
$this->campaign_source = $campaign_source;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @return string $campaign_source
|
183 |
+
*/
|
184 |
+
public function getCampaignSource() {
|
185 |
+
return $this->campaign_source;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* @param string $campaign_name
|
190 |
+
*/
|
191 |
+
public function setCampaignName($campaign_name) {
|
192 |
+
$this->campaign_name = $campaign_name;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @return string $campaign_name
|
197 |
+
*/
|
198 |
+
public function getCampaignName() {
|
199 |
+
return $this->campaign_name;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @param string $campaign_content
|
204 |
+
*/
|
205 |
+
public function setCampaignContent($campaign_content) {
|
206 |
+
$this->campaign_content = $campaign_content;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* @return string $campaign_content
|
211 |
+
*/
|
212 |
+
public function getCampaignContent() {
|
213 |
+
return $this->campaign_content;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* @param string $campaign_medium
|
218 |
+
*/
|
219 |
+
public function setCampaignMedium($campaign_medium) {
|
220 |
+
$this->campaign_medium = $campaign_medium;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* @return string $campaign_medium
|
225 |
+
*/
|
226 |
+
public function getCampaignMedium() {
|
227 |
+
return $this->campaign_medium;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* String demited list of keywords.
|
232 |
+
*
|
233 |
+
* @param string $campaign_term
|
234 |
+
*/
|
235 |
+
public function setCampaignTerm($campaign_term) {
|
236 |
+
$this->campaign_term = $campaign_term;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Space delimited list of keywords.
|
241 |
+
*
|
242 |
+
* @return string $campaign_term
|
243 |
+
*/
|
244 |
+
public function getCampaignTerm() {
|
245 |
+
return $this->campaign_term;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Array of strings of keywords derived from $campaign_term.
|
250 |
+
*
|
251 |
+
* @param array $keywords
|
252 |
+
*/
|
253 |
+
public function setKeywords(array $keywords = null) {
|
254 |
+
$this->keywords = $keywords;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Array of strings of keywords derived from $campaign_term.
|
259 |
+
*
|
260 |
+
* @return array $keywords
|
261 |
+
*/
|
262 |
+
public function getKeywords() {
|
263 |
+
return $this->keywords;
|
264 |
+
}
|
265 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Observer.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Flowecommerce_Resultadosdigitais_Model_Observer {
|
4 |
+
|
5 |
+
protected $_api = null;
|
6 |
+
protected $_helper = null;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Tipos de lead
|
10 |
+
*/
|
11 |
+
const LEAD_CONTACTFORM = 'contact-form';
|
12 |
+
const LEAD_ORDERPLACE = 'order-place';
|
13 |
+
const LEAD_ACCOUNTCREATE = 'account-create';
|
14 |
+
const LEAD_NEWSLETTERSUBSCRIBE = 'newsletter-subscribe';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Cliente tipo pessoa juridica - Compatibilidade com módulo PJ Flow
|
18 |
+
*/
|
19 |
+
const FPJ_PESSOA_JURIDICA_TYPE = 2;
|
20 |
+
|
21 |
+
protected function _getApi() {
|
22 |
+
if (is_null($this->_api)) {
|
23 |
+
$this->_api = Mage::getModel('resultadosdigitais/api');
|
24 |
+
}
|
25 |
+
return $this->_api;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _getGenderLabel($genderId) {
|
29 |
+
$return = null;
|
30 |
+
$attribute = Mage::getModel('eav/config')->getAttribute('customer', 'gender');
|
31 |
+
$allOptions = $attribute->getSource()->getAllOptions(true, true);
|
32 |
+
foreach ($allOptions as $instance) {
|
33 |
+
if ($instance['value'] == $genderId) {
|
34 |
+
$return = $instance['label'];
|
35 |
+
break;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
return $return;
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _getHelper() {
|
42 |
+
if (is_null($this->_helper)) {
|
43 |
+
$this->_helper = Mage::helper('resultadosdigitais');
|
44 |
+
}
|
45 |
+
return $this->_helper;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _getRequestDataObject() {
|
49 |
+
return Mage::getModel('resultadosdigitais/requestdata');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function contactPost(Varien_Event_Observer $observer) {
|
53 |
+
if ($this->_getHelper()->isEnabled()) {
|
54 |
+
$data = $observer->getData();
|
55 |
+
$post = $data['controller_action']->getRequest()->getPost();
|
56 |
+
|
57 |
+
$data = $this->_getRequestDataObject();
|
58 |
+
$data->setEmail($post['email']);
|
59 |
+
$data->setNome($post['name']);
|
60 |
+
$data->setTelefone($post['telephone']);
|
61 |
+
|
62 |
+
$this->_getApi()->addLeadConversion(self::LEAD_CONTACTFORM, $data);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
public function orderPlace(Varien_Event_Observer $observer) {
|
67 |
+
if ($this->_getHelper()->isEnabled()) {
|
68 |
+
/* @var Mage_Sales_Model_Order $order */
|
69 |
+
$order = $observer->getOrder();
|
70 |
+
/* @var Mage_Customer_Model_Customer $customer */
|
71 |
+
$customer = $order->getCustomer();
|
72 |
+
/* @var Mage_Sales_Model_Order_Address $address */
|
73 |
+
$address = $order->getBillingAddress();
|
74 |
+
|
75 |
+
$order_value = $order->getGrandTotal();
|
76 |
+
|
77 |
+
/*
|
78 |
+
* Dados da conta
|
79 |
+
*/
|
80 |
+
$data = $this->_getRequestDataObject();
|
81 |
+
$data->setEmail($customer->getEmail());
|
82 |
+
$data->setNome($customer->getName());
|
83 |
+
$data->setAniversario($customer->getDob());
|
84 |
+
$data->setGender($this->_getGenderLabel($customer->getGender()));
|
85 |
+
$data->setCpfCnpj($customer->getTaxvat());
|
86 |
+
|
87 |
+
|
88 |
+
/*
|
89 |
+
* Dados do endereço
|
90 |
+
*/
|
91 |
+
$data->setCidade($address->getCity());
|
92 |
+
$data->setTelefone($address->getTelephone());
|
93 |
+
$data->setCelular($address->getFax());
|
94 |
+
$data->setCep($address->getPostcode());
|
95 |
+
$data->setBairro($address->getStreet4());
|
96 |
+
|
97 |
+
# Empresa (verifica se módulo pj da flow está instalado)
|
98 |
+
$empresa = false;
|
99 |
+
if ($customer->getCompany() == self::FPJ_PESSOA_JURIDICA_TYPE) {
|
100 |
+
if ($customer->getFpjRazaoSocial()) {
|
101 |
+
$empresa = $customer->getFpjRazaoSocial();
|
102 |
+
}
|
103 |
+
} else if ($customer->getCompany()) {
|
104 |
+
$empresa = $customer->getCompany();
|
105 |
+
}
|
106 |
+
if ($empresa) {
|
107 |
+
$data->setEmpresa($empresa);
|
108 |
+
}
|
109 |
+
|
110 |
+
# Estado, caso esteja definido
|
111 |
+
if ($regionId = $address->getRegionId()) {
|
112 |
+
/* @var Mage_Directory_Model_Region $region */
|
113 |
+
$region = Mage::getModel('directory/region')->load($regionId);
|
114 |
+
$uf = $region->getName();
|
115 |
+
if ($uf) {
|
116 |
+
$data->setUf($uf);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->_getApi()->addLeadConversion(self::LEAD_ORDERPLACE, $data);
|
121 |
+
$this->_getApi()->markSale($customer->getEmail(), $order_value);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
public function registerSuccess(Varien_Event_Observer $observer) {
|
126 |
+
if ($this->_getHelper()->isEnabled()) {
|
127 |
+
/* @var Mage_Customer_Model_Customer $customer */
|
128 |
+
$customer = $observer->getCustomer();
|
129 |
+
|
130 |
+
/*
|
131 |
+
* Dados da conta
|
132 |
+
*/
|
133 |
+
$data = $this->_getRequestDataObject();
|
134 |
+
$data->setEmail($customer->getEmail());
|
135 |
+
$data->setNome($customer->getName());
|
136 |
+
$data->setAniversario($customer->getDob());
|
137 |
+
$data->setGender($this->_getGenderLabel($customer->getGender()));
|
138 |
+
$data->setCpfCnpj($customer->getTaxvat());
|
139 |
+
|
140 |
+
$this->_getApi()->addLeadConversion(self::LEAD_ACCOUNTCREATE, $data);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
public function newsletterSubscribe(Varien_Event_Observer $observer) {
|
145 |
+
if ($this->_getHelper()->isEnabled()) {
|
146 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
147 |
+
if ($subscriber->isSubscribed()) {
|
148 |
+
/*
|
149 |
+
* Dados da conta
|
150 |
+
*/
|
151 |
+
$data = $this->_getRequestDataObject();
|
152 |
+
$data->setEmail($subscriber->getEmail());
|
153 |
+
|
154 |
+
$this->_getApi()->addLeadConversion(self::LEAD_NEWSLETTERSUBSCRIBE, $data);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/Model/Requestdata.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Flowecommerce_Resultadosdigitais_Model_Requestdata extends Varien_Object {
|
4 |
+
|
5 |
+
}
|
app/code/local/Flowecommerce/Resultadosdigitais/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<resultadosdigitais translate="title" module="resultadosdigitais">
|
12 |
+
<title>Resultados Digitais</title>
|
13 |
+
<sort_order>600</sort_order>
|
14 |
+
</resultadosdigitais>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/local/Flowecommerce/Resultadosdigitais/etc/config.xml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Flowecommerce_Resultadosdigitais>
|
5 |
+
<version>0.1.1</version>
|
6 |
+
</Flowecommerce_Resultadosdigitais>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<resultadosdigitais>
|
11 |
+
<class>Flowecommerce_Resultadosdigitais_Model</class>
|
12 |
+
</resultadosdigitais>
|
13 |
+
</models>
|
14 |
+
<helpers>
|
15 |
+
<resultadosdigitais>
|
16 |
+
<class>Flowecommerce_Resultadosdigitais_Helper</class>
|
17 |
+
</resultadosdigitais>
|
18 |
+
</helpers>
|
19 |
+
<events>
|
20 |
+
<!-- formulário de contato enviado -->
|
21 |
+
<controller_action_postdispatch_contacts_index_post>
|
22 |
+
<observers>
|
23 |
+
<flowecommerce_resultadosdigitais_contacts_post>
|
24 |
+
<class>resultadosdigitais/observer</class>
|
25 |
+
<method>contactPost</method>
|
26 |
+
</flowecommerce_resultadosdigitais_contacts_post>
|
27 |
+
</observers>
|
28 |
+
</controller_action_postdispatch_contacts_index_post>
|
29 |
+
|
30 |
+
<!-- formulário de contato enviado - fileform -->
|
31 |
+
<controller_action_postdispatch_fileform_index_post>
|
32 |
+
<observers>
|
33 |
+
<flowecommerce_resultadosdigitais_fileform_post>
|
34 |
+
<class>resultadosdigitais/observer</class>
|
35 |
+
<method>contactPost</method>
|
36 |
+
</flowecommerce_resultadosdigitais_fileform_post>
|
37 |
+
</observers>
|
38 |
+
</controller_action_postdispatch_fileform_index_post>
|
39 |
+
|
40 |
+
<!-- criação de pedido -->
|
41 |
+
<sales_order_place_after>
|
42 |
+
<observers>
|
43 |
+
<flowecommerce_resultadosdigitais_order_place>
|
44 |
+
<class>resultadosdigitais/observer</class>
|
45 |
+
<method>orderPlace</method>
|
46 |
+
</flowecommerce_resultadosdigitais_order_place>
|
47 |
+
</observers>
|
48 |
+
</sales_order_place_after>
|
49 |
+
|
50 |
+
<!-- criação de conta de usuário -->
|
51 |
+
<customer_register_success>
|
52 |
+
<observers>
|
53 |
+
<flowecommerce_resultadosdigitais_register_success>
|
54 |
+
<class>resultadosdigitais/observer</class>
|
55 |
+
<method>registerSuccess</method>
|
56 |
+
</flowecommerce_resultadosdigitais_register_success>
|
57 |
+
</observers>
|
58 |
+
</customer_register_success>
|
59 |
+
|
60 |
+
<!-- assinatura da newsletter -->
|
61 |
+
<newsletter_subscriber_save_after>
|
62 |
+
<observers>
|
63 |
+
<flowecommerce_resultadosdigitais_newsletter_subscribe>
|
64 |
+
<class>resultadosdigitais/observer</class>
|
65 |
+
<method>newsletterSubscribe</method>
|
66 |
+
</flowecommerce_resultadosdigitais_newsletter_subscribe>
|
67 |
+
</observers>
|
68 |
+
</newsletter_subscriber_save_after>
|
69 |
+
</events>
|
70 |
+
</global>
|
71 |
+
</config>
|
app/code/local/Flowecommerce/Resultadosdigitais/etc/system.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<resultadosdigitais translate="label" module="resultadosdigitais">
|
5 |
+
<label>Flow eCommerce</label>
|
6 |
+
<sort_order>600</sort_order>
|
7 |
+
</resultadosdigitais>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<resultadosdigitais>
|
11 |
+
<label>Integração com RD Station</label>
|
12 |
+
<tab>resultadosdigitais</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>10</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>0</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<general translate="label">
|
20 |
+
<label>Resultados Digitais</label>
|
21 |
+
<sort_order>100</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<fields>
|
26 |
+
<enable translate="label">
|
27 |
+
<label>Ativo?</label>
|
28 |
+
<frontend_type>select</frontend_type>
|
29 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
30 |
+
<sort_order>10</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
</enable>
|
35 |
+
<token translate="label">
|
36 |
+
<label>Token</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>20</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>0</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
</token>
|
43 |
+
<private_token translate="label">
|
44 |
+
<label>Token Privado</label>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<sort_order>30</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
</private_token>
|
51 |
+
</fields>
|
52 |
+
</general>
|
53 |
+
</groups>
|
54 |
+
</resultadosdigitais>
|
55 |
+
</sections>
|
56 |
+
</config>
|
app/etc/modules/Flowecommerce_Resultadosdigitais.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Flowecommerce_Resultadosdigitais>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Flowecommerce_Resultadosdigitais>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>flowecommerce_resultadosdigitais</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Módulo de integração entre o magento e a plataforma RD Station da Resultados Digitais para criação e qualificação de leads.</summary>
|
10 |
+
<description>Módulo de integração entre o magento e a plataforma RD Station da Resultados Digitais para criação e qualificação de leads.
|
11 |
+

|
12 |
+
Este módulo executa chamadas para a API do RDStation quando:
|
13 |
+

|
14 |
+
Um formulário de contato é enviado
|
15 |
+
Uma nova conta de cliente é criada
|
16 |
+
Um novo pedido é criado
|
17 |
+
Um cliente assina a newsletter da loja virtual</description>
|
18 |
+
<notes>Módulo de integração entre o magento e a plataforma RD Station da Resultados Digitais para criação e qualificação de leads.
|
19 |
+

|
20 |
+
Este módulo executa chamadas para a API do RDStation quando:
|
21 |
+

|
22 |
+
Um formulário de contato é enviado
|
23 |
+
Uma nova conta de cliente é criada
|
24 |
+
Um novo pedido é criado
|
25 |
+
Um cliente assina a newsletter da loja virtual</notes>
|
26 |
+
<authors><author><name>Flow eCommerce</name><user>flowecommerce</user><email>contato@flowecommerce.com</email></author><author><name>Gabriel Queiroz Silva</name><user>gabrielqs</user><email>gabriel@flowecommerce.com</email></author></authors>
|
27 |
+
<date>2014-12-05</date>
|
28 |
+
<time>11:37:31</time>
|
29 |
+
<contents><target name="magelocal"><dir name="Flowecommerce"><dir name="Resultadosdigitais"><dir name="Helper"><file name="Data.php" hash="00d2ae49825e162eb99dd72a98895a61"/></dir><dir name="Model"><file name="Api.php" hash="3d1f6c2f0406e79aa11245b46c9df874"/><dir name="Googleanalytics"><file name="Customvar.php" hash="d163ebb5bb590dd7553ed1356c033a2c"/><file name="Tracker.php" hash="be95e10bd1df9ca5319f5a50967f2eed"/><dir name="Utm"><file name="A.php" hash="7604206d87189c56f109231c4a95f00f"/><file name="B.php" hash="e710a66f3c061f4da69e9f468c2eaf5c"/><file name="C.php" hash="27c99ca82b05b11bcba01e88f9a3e5c6"/><file name="V.php" hash="9c77ced8175034ac42b89878e26844f5"/><file name="Z.php" hash="1bb0821f8752993b737a923fcbd4b314"/></dir></dir><file name="Observer.php" hash="3b502ffb66429c620b272d3e534ee6c7"/><file name="Requestdata.php" hash="d97634793fae544f18e5ffda617ed745"/></dir><dir name="etc"><file name="adminhtml.xml" hash="be9b06eed9df502e9759b5cd397f9fa2"/><file name="config.xml" hash="895bd2d9a76ff3bc31811dd2129c0b9f"/><file name="system.xml" hash="da64ea97bc98fe6f42988df79c2ace1f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flowecommerce_Resultadosdigitais.xml" hash="5d476dea8a51bda77126fa637c5f29f2"/></dir></target></contents>
|
30 |
+
<compatible/>
|
31 |
+
<dependencies><required><php><min>5.3.0</min><max>5.6.3</max></php></required></dependencies>
|
32 |
+
</package>
|