org.broadleafcommerce.core.web.processor
Class GoogleAnalyticsProcessor

java.lang.Object
  extended by org.thymeleaf.processor.AbstractProcessor
      extended by org.thymeleaf.processor.element.AbstractElementProcessor
          extended by org.broadleafcommerce.common.web.dialect.AbstractModelVariableModifierProcessor
              extended by org.broadleafcommerce.core.web.processor.GoogleAnalyticsProcessor
All Implemented Interfaces:
Comparable<org.thymeleaf.processor.IProcessor>, org.thymeleaf.processor.IProcessor

@Component(value="blGoogleAnalyticsProcessor")
public class GoogleAnalyticsProcessor
extends AbstractModelVariableModifierProcessor

A Thymeleaf processor that will on order confirmation page, submit order information via javascript to google analytics. Example usage on order confirmation page:

  <blc:googleAnalytics th:attr="orderNumber=${order != null ? order.orderNumber : null}" />
      <script th:utext="${analytics}" />
  
 

Author:
tleffert

Field Summary
protected  String affiliation
           
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
           
 
Constructor Summary
GoogleAnalyticsProcessor()
          Sets the name of this processor to be used in Thymeleaf template
 
Method Summary
protected  String analytics(String webPropertyId, Order order)
          Documentation for the recommended asynchronous GA tag is at: http://code.google.com/apis/analytics/docs/tracking/gaTrackingEcommerce.html
 String getAffiliation()
           
protected  Address getBillingAddress(Order order)
           
 int getPrecedence()
           
 boolean getTestLocal()
           
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
protected  void modifyModelAttributes(org.thymeleaf.Arguments arguments, org.thymeleaf.dom.Element element)
           
 void setAffiliation(String affiliation)
           
protected  void setTestLocal(boolean testLocal)
           
 
Methods inherited from class org.broadleafcommerce.common.web.dialect.AbstractModelVariableModifierProcessor
addToModel, processElement
 
Methods inherited from class org.thymeleaf.processor.element.AbstractElementProcessor
doProcess, getMatcher
 
Methods inherited from class org.thymeleaf.processor.AbstractProcessor
compareTo, getMessage, getMessageForProcessor, getMessageForTemplate, process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orderService

protected OrderService orderService

webPropertyId

@Value(value="${googleAnalytics.webPropertyId}")
protected String webPropertyId

affiliation

@Value(value="${googleAnalytics.affiliation}")
protected String affiliation

testLocal

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 Detail

GoogleAnalyticsProcessor

public GoogleAnalyticsProcessor()
Sets the name of this processor to be used in Thymeleaf template

Method Detail

getPrecedence

public int getPrecedence()
Specified by:
getPrecedence in class org.thymeleaf.processor.AbstractProcessor

modifyModelAttributes

protected void modifyModelAttributes(org.thymeleaf.Arguments arguments,
                                     org.thymeleaf.dom.Element element)
Specified by:
modifyModelAttributes in class AbstractModelVariableModifierProcessor

analytics

protected String analytics(String webPropertyId,
                           Order order)
Documentation for the recommended asynchronous GA tag is at: http://code.google.com/apis/analytics/docs/tracking/gaTrackingEcommerce.html

Parameters:
webPropertyId - - Google Analytics ID
order - - optionally track the order submission. This should be included on the page after the order has been sucessfully submitted. If null, this will just track the current page
Returns:
the relevant Javascript to render on the page

getVariation

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

Returns:

getBillingAddress

protected Address getBillingAddress(Order order)

setTestLocal

protected void setTestLocal(boolean testLocal)

getTestLocal

public boolean getTestLocal()

getAffiliation

public String getAffiliation()

setAffiliation

public void setAffiliation(String affiliation)


Copyright © 2013. All Rights Reserved.