\GTMdata
GTMdata
This class creates a persistent container for all dataLayer values and is
used by the GTM class to store and retrieve data.
- Author: <andrewm@cyber-duck.co.uk>
- License: MIT License https://github.com/cyber-duck/silverstripe-google-tag-manager/blob/master/LICENSE
Synopsis
class GTMdata
{
- // members
- private static array $data = ;
- private static string $json = '';
- private static $currency;
- // methods
- public static void pushData()
- public static void pushEvent()
- public static void pushTransactionCurrency()
- public static void pushProductImpression()
- public static void pushProductPromoImpression()
- public static void pushProductDetail()
- public static void pushAddToCart()
- public static void pushRemoveFromCart()
- public static void pushPurchase()
- public static void pushPurchaseItem()
- public static void pushRefundTransaction()
- public static void pushRefundTransactionItem()
- public static void pushCartAction()
- public static string getDataLayer()
- private static array getDefaults()
- private static void pushCurrent()
- private void __construct()
- private void __clone()
- private void __wakeup()
Members
private
- $currency
—
string
The current dataLayer currency e.g EUR - $data
—
array
The Tag Manager dataLayer array of values - $json
—
string
The datalayer JSON string
Methods
private
- __construct() — Private constructor
- __clone() — Private clone
- __wakeup() — Private wakeup
- getDefaults() — Compare an array against an array of required fields for a dataLayer property
- pushCurrent() — Create a dataLayer push from the current data array
public
- getDataLayer() — Get the complete formatted dataLayer
- pushAddToCart() — Push a cart add action to the data array
- pushCartAction() — Push a cart action to the data array
- pushData() — Push a key value pair to the data array
- pushEvent() — Push an event to the data array
- pushProductDetail() — Push a product detail view fields to the data array
- pushProductImpression() — Push a product impression to the data array
- pushProductPromoImpression() — Push a product promotional impression to the data array
- pushPurchase() — Push a purchase to the data array
- pushPurchaseItem() — Push a purchase item fields to the data array
- pushRefundTransaction() — Push a refund to the data array
- pushRefundTransactionItem() — Push a refund item to the data array
- pushRemoveFromCart() — Push a cart remove action to the data array
- pushTransactionCurrency() — Push a transaction currency the data array