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 |
affiliation |
protected boolean |
includeDisplayAdvertising |
protected boolean |
includeLinkAttribution |
protected String |
masterWebPropertyId
Global value
|
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
|
protected String |
webPropertyId
Site-specific value
|
| Constructor and Description |
|---|
GoogleUniversalAnalyticsProcessor() |
GoogleUniversalAnalyticsProcessor(String elementName) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAffiliation() |
protected String |
getDisplayAdvertisingJs(String tracker)
Builds the display advertising Javascript for the given tracker
|
protected String |
getItemJs(Order order,
String tracker) |
protected String |
getLinkAttributionJs(String tracker)
Builds the linke attribution Javascript
|
String |
getMasterWebPropertyId() |
OrderService |
getOrderService() |
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 tracker)
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 |
setAffiliation(String affiliation) |
void |
setIncludeDisplayAdvertising(boolean includeDisplayAdvertising) |
void |
setIncludeLinkAttribution(boolean includeLinkAttribution) |
void |
setMasterWebPropertyId(String masterWebPropertyId) |
void |
setOrderService(OrderService orderService) |
void |
setWebPropertyId(String webPropertyId) |
doProcess, getMatcher@Value(value="${googleAnalytics.masterWebPropertyId:}")
protected String masterWebPropertyId
@Value(value="${googleAnalytics.webPropertyId:}")
protected String webPropertyId
@Value(value="${googleAnalytics.affiliation:}")
protected String affiliation
@Value(value="${googleAnalytics.enableLinkAttribution:true}")
protected boolean includeLinkAttribution
@Value(value="${googleAnalytics.enableDisplayAdvertising:false}")
protected boolean includeDisplayAdvertising
protected OrderService orderService
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 String getLinkAttributionJs(String tracker)
tracker - the name of the tracker that is using the link attributionprotected String getDisplayAdvertisingJs(String tracker)
tracker - protected String getTransactionJs(Order order, String tracker)
protected String getVariation(OrderItem item)
public OrderService getOrderService()
public void setOrderService(OrderService orderService)
public String getMasterWebPropertyId()
public void setMasterWebPropertyId(String masterWebPropertyId)
public String getAffiliation()
public void setAffiliation(String affiliation)
public String getWebPropertyId()
public void setWebPropertyId(String webPropertyId)
public boolean isIncludeLinkAttribution()
public void setIncludeLinkAttribution(boolean includeLinkAttribution)
public boolean isIncludeDisplayAdvertising()
public void setIncludeDisplayAdvertising(boolean includeDisplayAdvertising)
Copyright © 2014. All Rights Reserved.