class Create in Googalytics - Google Analytics 8
Class Create.
Hierarchy
- class \Drupal\ga\AnalyticsCommand\Generic implements DrupalSettingCommandsInterface uses DrupalSettingCommandsTrait
- class \Drupal\ga\AnalyticsCommand\Create
Expanded class hierarchy of Create
2 files declare their use of Create
- CreateTest.php in tests/
src/ Unit/ AnalyticsCommand/ CreateTest.php - DefaultCommandSubscriber.php in src/
EventSubscriber/ DefaultCommandSubscriber.php
File
- src/
AnalyticsCommand/ Create.php, line 8
Namespace
Drupal\ga\AnalyticsCommandView source
class Create extends Generic {
const DEFAULT_PRIORITY = 300;
/**
* The Google Analytics property ID.
*
* @var string
*/
protected $trackingId;
/**
* The analytics cookie domain.
*
* @var string
*/
protected $cookieDomain;
/**
* Create constructor.
*
* @param string $tracking_id
* A Google Analytics property ID.
* @param string $cookie_domain
* The cookie domain.
* @param string $tracker_name
* The tracker name.
* @param array $fields_object
* A set of additional options for the command.
* @param int $priority
* The command priority.
*/
public function __construct($tracking_id, $cookie_domain = 'auto', $tracker_name = NULL, array $fields_object = [], $priority = self::DEFAULT_PRIORITY) {
parent::__construct('create', $fields_object, $tracker_name, $priority);
$this->trackingId = $tracking_id;
$this->cookieDomain = $cookie_domain;
}
/**
* Get the tracking id.
*
* @return string
* The tracking id.
*/
public function getTrackingId() {
return $this->trackingId;
}
/**
* Get the cookie domain.
*
* @return string
* The cookie domain.
*/
public function getCookieDomain() {
return $this->cookieDomain;
}
/**
* {@inheritdoc}
*/
public function getSettingCommands() {
$command = [
$this->command,
$this->trackingId,
$this->cookieDomain,
];
if (!empty($this->trackerName)) {
$command[] = $this->trackerName;
}
if (!empty($this->fieldsObject)) {
$command[] = $this->fieldsObject;
}
return [
$command,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Create:: |
protected | property | The analytics cookie domain. | |
Create:: |
protected | property | The Google Analytics property ID. | |
Create:: |
constant |
Overrides Generic:: |
||
Create:: |
public | function | Get the cookie domain. | |
Create:: |
public | function |
An array of commands to be sent to Google Analytics. Overrides Generic:: |
|
Create:: |
public | function | Get the tracking id. | |
Create:: |
public | function |
Create constructor. Overrides Generic:: |
|
DrupalSettingCommandsTrait:: |
protected | property | Priority integer. | |
DrupalSettingCommandsTrait:: |
public | function | An integer value for sorting by priority. | |
Generic:: |
protected | property | The command name. | |
Generic:: |
protected | property | A map of values for the command's fieldsObject parameter. | |
Generic:: |
protected | property | The name of the tracker for this command. | |
Generic:: |
public | function | Get the command name. | |
Generic:: |
public | function | Get the map of values for the command's fieldsObject parameter. | |
Generic:: |
public | function | The tracker this command will be applied to, if specified. |