public class GoogleUniversalAnalyticsProcessor
extends org.thymeleaf.processor.element.AbstractElementProcessor
Takes advantage of the new-stype analytics.js from Google Analytics rather than the deprected ga.js. This also supports a pre-processed orderNumber attribute that can be null, suitable for things like the order confirmation page to send e-commerce transactions. Example usage:
<google_universal_analytics ordernumber="${order?.orderNumber" />
This processor also supports:
getTrackers() or by setting the googleAnalytics.masterWebPropertyId
and googleAnalytics.webPropertyId)googleAnalytics.enableLinkAttribution system property, default true)googleAnalytics.enableDisplayAdvertising system property, default false)| Modifier and Type | Field and Description |
|---|---|
protected String |
masterWebPropertyId
Global value, intentionally only retrieved as a file property NOT via the system properties service
|
protected OrderService |
orderService |
protected boolean |
testLocal
This will force the domain to 127.0.0.1 which is useful to determine if the Google Analytics tag is sending
a request to Google
|
| Constructor and Description |
|---|
GoogleUniversalAnalyticsProcessor() |
GoogleUniversalAnalyticsProcessor(String elementName) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAffiliation() |
protected String |
getDisplayAdvertisingJs(String trackerPrefix)
Builds the display advertising Javascript for the given tracker
|
protected String |
getItemJs(Order order,
String trackerPrefix) |
protected String |
getLinkAttributionJs(String trackerPrefix)
Builds the linke attribution Javascript
|
String |
getMasterWebPropertyId() |
int |
getPrecedence() |
protected Map<String,String> |
getTrackers()
Grabs a map of trackers keyed by the tracker name with the analytics ID as the value
|
protected String |
getTransactionJs(Order order,
String trackerPrefix)
Builds the transaction analytics for the given tracker name.
|
protected String |
getVariation(OrderItem item)
Returns the product option values separated by a space if they are
relevant for the item, or the product category if no options are available
|
String |
getWebPropertyId() |
boolean |
isIncludeDisplayAdvertising() |
boolean |
isIncludeLinkAttribution() |
protected org.thymeleaf.processor.ProcessorResult |
processElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element) |
void |
setMasterWebPropertyId(String masterWebPropertyId) |
protected boolean |
shouldShowMasterTracker() |
doProcess, getMatcher@Value(value="${googleAnalytics.masterWebPropertyId}")
protected String masterWebPropertyId
protected OrderService orderService
@Value(value="${googleAnalytics.testLocal}")
protected boolean testLocal
public GoogleUniversalAnalyticsProcessor()
public GoogleUniversalAnalyticsProcessor(String elementName)
public int getPrecedence()
getPrecedence in class org.thymeleaf.processor.AbstractProcessorprotected org.thymeleaf.processor.ProcessorResult processElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element)
processElement in class org.thymeleaf.processor.element.AbstractElementProcessorprotected Map<String,String> getTrackers()
protected boolean shouldShowMasterTracker()
protected String getLinkAttributionJs(String trackerPrefix)
tracker - the name of the tracker that is using the link attributionprotected String getDisplayAdvertisingJs(String trackerPrefix)
tracker - protected String getTransactionJs(Order order, String trackerPrefix)
protected String getVariation(OrderItem item)
public String getMasterWebPropertyId()
public void setMasterWebPropertyId(String masterWebPropertyId)
public String getAffiliation()
public String getWebPropertyId()
public boolean isIncludeLinkAttribution()
public boolean isIncludeDisplayAdvertising()
Copyright © 2015. All Rights Reserved.