PHP Class Craft\InstantAnalyticsService

Inheritance: extends craft\BaseApplicationComponent
Datei anzeigen Open project: nystudio107/instantanalytics

Protected Properties

Property Type Description
$cachedAnalytics

Public Methods

Method Description
addCommerceCheckoutStep ( IAnalytics $analytics = null, Commerce_OrderModel $orderModel = null, integer $step = 1, string $option = "" ) Add a checkout step and option to an Analytics object
addCommerceOrderToAnalytics ( IAnalytics $analytics = null, Commerce_OrderModel $orderModel = null ) Add a Craft Commerce OrderModel to an Analytics object
addCommerceProductDetailView ( IAnalytics $analytics = null, $productVariant = null ) Add a product detail view from a Craft Commerce Product or Variant
addCommerceProductImpression ( IAnalytics $analytics = null, $productVariant = null, integer $index, $listName = "" ) Add a product impression from a Craft Commerce Product or Variant
addProductDataFromLineItem ( $analytics = null, $lineItem = null, $index, $listName = "" ) : string Add a Craft Commerce LineItem to an Analytics object
addToCart ( Commerce_OrderModel $orderModel = null, Commerce_LineItemModel $lineItem = null ) Send analytics information for the item added to the cart
analytics ( ) : Analytics getAnalyticsObject() return an analytics object
eventAnalytics ( $eventCategory = "", $eventAction = "", $eventLabel = "", $eventValue ) : Analytics Get an Event analytics object
eventTrackingUrl ( string $url, string $eventCategory = "", string $eventAction = "", string $eventLabel = "", string $eventValue ) : string Get an Event tracking URL
getGlobals ( $title ) : array Get the global variables for our Twig context
getProductDataFromProduct ( $productVariant = null, $index, $listName = "" ) : array Extract product data from a Craft Commerce Product or Variant
orderComplete ( Commerce_OrderModel $orderModel = null ) Send analytics information for the completed order
pageViewAnalytics ( $url = "", $title = "" ) : Analytics Get a PageView analytics object
pageViewTrackingUrl ( string $url, string $title ) : string Get a PageView tracking URL
removeFromCart ( $orderModel = null, $lineItem = null ) Send analytics information for the item removed from the cart
shouldSendAnalytics ( ) : boolean _shouldSendAnalytics determines whether we should be sending Google Analytics data

Private Methods

Method Description
_gaGenUUID ( ) : string _gaGenUUID Generate UUID v4 function - needed to generate a CID when one isn't available
_gaParseCookie ( ) : string _gaParseCookie handles the parsing of the _ga cookie or setting it to a unique identifier
_getAnalyticsObj ( ) : Analytics Get the Google Analytics object, primed with the default values
_getGclid ( ) _getGclid get the gclid and sets the 'gclid' cookie
_pullDataFromField ( $productVariant, $fieldHandle ) : string Extract the value of a field

Method Details

addCommerceCheckoutStep() public method

Add a checkout step and option to an Analytics object
public addCommerceCheckoutStep ( IAnalytics $analytics = null, Commerce_OrderModel $orderModel = null, integer $step = 1, string $option = "" )
$analytics IAnalytics the Analytics object
$orderModel Commerce_OrderModel the Product or Variant
$step integer the checkout step
$option string the checkout option

addCommerceOrderToAnalytics() public method

Add a Craft Commerce OrderModel to an Analytics object
public addCommerceOrderToAnalytics ( IAnalytics $analytics = null, Commerce_OrderModel $orderModel = null )
$analytics IAnalytics the Analytics object
$orderModel Commerce_OrderModel the Product or Variant

addCommerceProductDetailView() public method

Add a product detail view from a Craft Commerce Product or Variant
public addCommerceProductDetailView ( IAnalytics $analytics = null, $productVariant = null )
$analytics IAnalytics the Analytics object

addCommerceProductImpression() public method

Add a product impression from a Craft Commerce Product or Variant
public addCommerceProductImpression ( IAnalytics $analytics = null, $productVariant = null, integer $index, $listName = "" )
$analytics IAnalytics the Analytics object
$index integer Where the product appears in the list

addProductDataFromLineItem() public method

Add a Craft Commerce LineItem to an Analytics object
public addProductDataFromLineItem ( $analytics = null, $lineItem = null, $index, $listName = "" ) : string
return string the title of the product

addToCart() public method

Send analytics information for the item added to the cart
public addToCart ( Commerce_OrderModel $orderModel = null, Commerce_LineItemModel $lineItem = null )
$orderModel Commerce_OrderModel the Product or Variant
$lineItem Commerce_LineItemModel the line item that was added

analytics() public method

getAnalyticsObject() return an analytics object
public analytics ( ) : Analytics
return TheIconic\Tracking\GoogleAnalytics\Analytics object

eventAnalytics() public method

Get an Event analytics object
public eventAnalytics ( $eventCategory = "", $eventAction = "", $eventLabel = "", $eventValue ) : Analytics
return TheIconic\Tracking\GoogleAnalytics\Analytics object

eventTrackingUrl() public method

Get an Event tracking URL
public eventTrackingUrl ( string $url, string $eventCategory = "", string $eventAction = "", string $eventLabel = "", string $eventValue ) : string
$url string the URL to track
$eventCategory string the event category
$eventAction string the event action
$eventLabel string the event label
$eventValue string the event value
return string the tracking URL

getGlobals() public method

Get the global variables for our Twig context
public getGlobals ( $title ) : array
return array with 'instantAnalytics' => Analytics object

getProductDataFromProduct() public method

Extract product data from a Craft Commerce Product or Variant
public getProductDataFromProduct ( $productVariant = null, $index, $listName = "" ) : array
return array the product data

orderComplete() public method

Send analytics information for the completed order
public orderComplete ( Commerce_OrderModel $orderModel = null )
$orderModel Commerce_OrderModel the Product or Variant

pageViewAnalytics() public method

Get a PageView analytics object
public pageViewAnalytics ( $url = "", $title = "" ) : Analytics
return TheIconic\Tracking\GoogleAnalytics\Analytics object

pageViewTrackingUrl() public method

Get a PageView tracking URL
public pageViewTrackingUrl ( string $url, string $title ) : string
$url string the URL to track
$title string the page title
return string the tracking URL

removeFromCart() public method

Send analytics information for the item removed from the cart
public removeFromCart ( $orderModel = null, $lineItem = null )

shouldSendAnalytics() public method

_shouldSendAnalytics determines whether we should be sending Google Analytics data
public shouldSendAnalytics ( ) : boolean
return boolean

Property Details

$cachedAnalytics protected_oe property

protected $cachedAnalytics