Class GoogleAnalytics4Processor
java.lang.Object
org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
org.broadleafcommerce.core.web.processor.GoogleAnalytics4Processor
- Record Components:
ordernumber- the order number to look up for ecommerce tracking, such as on the confirmation page
- All Implemented Interfaces:
org.broadleafcommerce.presentation.dialect.BroadleafProcessor,org.broadleafcommerce.presentation.dialect.BroadleafTagReplacementProcessor
@Component("blGoogleAnalytics4Processor")
@ConditionalOnTemplating
public class GoogleAnalytics4Processor
extends org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
Takes advantage of the new-type gtag.js from Google Analytics rather than the deprecated analytics.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_analytics_4 ordernumber="${order?.orderNumber" />
This processor also supports:
- Multiple trackers (extensible via
#getTrackers()or by setting thegoogleAnalytics4.masterWebPropertyIdandgoogleAnalytics4.webPropertyId) - Affiliates for e-commerce ({@ googleAnalytics.affiliation property})
- Link attribution
(
googleAnalytics4.enableLinkAttributionsystem property, defaulttrue) - Display Advertising
(
googleAnalytics4.enableDisplayAdvertisingsystem property, defaultfalse)
- Author:
- Markiian Buryi (MarekB01)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringGlobal value, intentionally only retrieved as a file property NOT via the system properties serviceprotected Stringprotected org.broadleafcommerce.core.order.service.OrderServiceprotected Stringprotected booleanThis will force the domain to 127.0.0.1 which is useful to determine if the Google Analytics tag is sending a request to GoogleFields inherited from interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
DEFAULT_PRECEDENCE, DEFAULT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetItemJs(org.broadleafcommerce.core.order.domain.Order order) getName()intorg.broadleafcommerce.presentation.model.BroadleafTemplateModelgetReplacementModel(String tagName, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) protected StringgetTransactionJs(org.broadleafcommerce.core.order.domain.Order order) /** Builds the transaction analytics for the given tracker name.protected StringgetVariation(org.broadleafcommerce.core.order.domain.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 availablebooleanbooleanMethods inherited from class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
getPrefix, replacementNeedsProcessing
-
Field Details
-
googleAnalytics4PropertyId
Global value, intentionally only retrieved as a file property NOT via the system properties service -
googleAnalytics4WebPropertyId
-
tagId
-
orderService
protected org.broadleafcommerce.core.order.service.OrderService orderService -
testLocal
@Value("${googleAnalytics4.testLocal:false}") protected boolean testLocalThis 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 Details
-
GoogleAnalytics4Processor
public GoogleAnalytics4Processor()
-
-
Method Details
-
getName
-
getPrecedence
public int getPrecedence()- Specified by:
getPrecedencein interfaceorg.broadleafcommerce.presentation.dialect.BroadleafProcessor- Overrides:
getPrecedencein classorg.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
-
getReplacementModel
-
getTransactionJs
/** Builds the transaction analytics for the given tracker name. Invokesfor each item in the given <b>order</b>. -
getItemJs
-
getVariation
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:
-
getTagIdForProperty
-
getWebPropertyId
-
getAffiliation
-
isIncludeLinkAttribution
public boolean isIncludeLinkAttribution() -
isIncludeDisplayAdvertising
public boolean isIncludeDisplayAdvertising()
-