@Component(value="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:
#getTrackers() or by setting the googleAnalytics4.masterWebPropertyId
and googleAnalytics4.webPropertyId)googleAnalytics4.enableLinkAttribution system property, default true)googleAnalytics4.enableDisplayAdvertising system property, default false)| Modifier and Type | Field and Description |
|---|---|
protected String |
googleAnalytics4PropertyId
Global value, intentionally only retrieved as a file property NOT via the system properties service
|
protected String |
googleAnalytics4WebPropertyId |
protected OrderService |
orderService |
protected String |
tagId |
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 |
|---|
GoogleAnalytics4Processor() |
| Modifier and Type | Method and Description |
|---|---|
String |
getAffiliation() |
protected String |
getItemJs(Order order) |
String |
getName() |
int |
getPrecedence() |
org.broadleafcommerce.presentation.model.BroadleafTemplateModel |
getReplacementModel(String tagName,
Map<String,String> tagAttributes,
org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) |
String |
getTagIdForProperty() |
protected String |
getTransactionJs(Order order)
/**
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() |
@Value(value="${googleAnalytics4.masterWebPropertyId:null}")
protected String googleAnalytics4PropertyId
@Value(value="${googleAnalytics4.webPropertyId:null}")
protected String googleAnalytics4WebPropertyId
@Value(value="${googleAnalytics4.tagIdForProperty:null}")
protected String tagId
protected OrderService orderService
@Value(value="${googleAnalytics4.testLocal:false}")
protected boolean testLocal
public String getName()
public int getPrecedence()
getPrecedence in interface org.broadleafcommerce.presentation.dialect.BroadleafProcessorgetPrecedence in class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessorpublic org.broadleafcommerce.presentation.model.BroadleafTemplateModel getReplacementModel(String tagName, Map<String,String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
protected String getTransactionJs(Order order)
protected String getVariation(OrderItem item)
public String getTagIdForProperty()
public String getWebPropertyId()
public String getAffiliation()
public boolean isIncludeLinkAttribution()
public boolean isIncludeDisplayAdvertising()
Copyright © 2025. All rights reserved.