Spork Code Libraries

GoogleAnalytic

Render Google Analytics tracking code.

The helper adds the code to the InlineScript view helper when it is initialized. It is important that the helper is only initialized once. This can be done automatically by using the Spork InlineScript view helper which initialized this helper when it is rendered.

Extends
\Zend\Form\View\Helper\AbstractHelper
Implements

Properties

$initialized

$initialized : boolean

Has the helper been initialized

Type

boolean

$trackingId

$trackingId : string

The Google tracking ID

Type

string

Methods

createService()

createService(\Zend\ServiceManager\ServiceLocatorInterface  $viewHelperManager) : \Spork\View\Helper\GoogleAnalytic

Create and configure helper instance

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $viewHelperManager

Returns

\Spork\View\Helper\GoogleAnalytic
See also

setTrackingId()

setTrackingId(string  $id) 

Set Google Analytics tracking ID

Parameters

string $id

getTrackingId()

getTrackingId() : string

Get Google Analytics tracking ID

Returns

string

config()

config(array  $options) 

Configure helper

Parameters

array $options

initialize()

initialize() 

Inject Google Analytics tracker code into InlineScript helper. This should only be called once after the helper is completely configured.