\GTM
GTM
A module to allow the easy implementation of Google Tag Manager within the
Silverstripe framework. The GTM module is meant to cater for any features of
Google Tag Manager that must be "hard coded" with a page. Data layer variables
and ecommerce features such as purchases can be easily be inserted within a page
through your controller functionality without having to edit your ss templates.
Instead of building the datalayer JavScript straight away, all data layer values
are stored in static arrays which are converted into JavScript once we call our
Tag Manager snippet.
- Author: <andrewm@cyber-duck.co.uk>
- License: MIT License https://github.com/cyber-duck/silverstripe-google-tag-manager/blob/master/LICENSE
Synopsis
class GTM
{
- // methods
- public static string snippet()
- public static void data()
- public static void event()
- public static void transactionCurrency()
- public static void productImpression()
- public static void productPromoImpression()
- public static void productDetail()
- public static void addToCart()
- public static void removeFromCart()
- public static void purchase()
- public static void purchaseItem()
- public static void refundTransaction()
- public static void refundItem()
Methods
public
- addToCart() — Record a product being added to the cart
- data() — Set a dataLayer key value pair
- event() — Push an event to the dataLayer
- productDetail() — Record a product detail page
- productImpression() — Record a product impression
- productPromoImpression() — Record a product impression in a promotional space
- purchase() — Add an ecommerce transaction
- purchaseItem() — Add an ecommerce transaction item Used in conjunction with ->purchase()
- refundItem() — Refund an ecommerce transaction item
- refundTransaction() — Refund an ecommerce transaction
- removeFromCart() — Record a product being removed from the cart
- snippet() — Returns the complete data layer and Google Tag Manager snippet. Inject in the container ID (GTM-XXXXX). Only the XXXXX part is required for injection.
- transactionCurrency() — Add the ecommerce transaction currency code