-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Google data layer #2613
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
@Configuration(label="Data Layer", description="Configure support for Adobe Client Data Layer") | ||
public @interface DataLayerConfig { | ||
|
||
String DATALAYER_OBJECT_NAME_ADOBE = "adobeDataLayer"; | ||
|
||
/** | ||
* | ||
* @return {@code true} if the data layer is enabled, {@code false} otherwise. It defaults to {@code false}. | ||
|
@@ -39,4 +41,29 @@ | |
@Property(label="Data Layer client library not included") | ||
boolean skipClientlibInclude() default false; | ||
|
||
/** | ||
* | ||
* @return the name of the datalayer | ||
* Defaults to adobeDataLayer. | ||
*/ | ||
@Property(label = "Data Layer object name") | ||
String name() default DATALAYER_OBJECT_NAME_ADOBE; | ||
|
||
/** | ||
* | ||
* @return the type of push function (push() or gtag()) of the datalayer | ||
* Defaults to push. | ||
*/ | ||
@Property(label = "Use gtag function to push data") | ||
boolean pushFunctionUseGtag() default false; | ||
|
||
/** | ||
* | ||
* @return ACDL library not included | ||
* Defaults to false. | ||
*/ | ||
@Property(label = "ACDL library not included") | ||
boolean skipAcdlInclude() default false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see reply to Paga.java above |
||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
@ConsumerType | ||
public interface Page extends ContainerExporter, Component { | ||
|
||
String DATALAYER_OBJECT_NAME_ADOBE = "adobeDataLayer"; | ||
|
||
/** | ||
* Key used for the regular favicon file. | ||
* | ||
|
@@ -467,4 +469,27 @@ default List<String> getRobotsTags() { | |
*/ | ||
default boolean isDataLayerClientlibIncluded() {return true;} | ||
|
||
/** | ||
* Returns the name of the data layer. | ||
* | ||
* {@code true} if the data layer client library should be included. | ||
* @since om.adobe.cq.wcm.core.components.models 12.24.0 | ||
*/ | ||
default String getDataLayerName() { return DATALAYER_OBJECT_NAME_ADOBE; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will require a package minor version bump |
||
|
||
/** | ||
* Checks if gtag() should be used to push to the data layer. | ||
* | ||
* {@code true} if gtag() should be used. | ||
* @since om.adobe.cq.wcm.core.components.models 12.24.0 | ||
*/ | ||
default boolean isDataLayerUseGtag() { return false; }; | ||
|
||
/** | ||
* Checks if the ACDL library should be included. | ||
* | ||
* {@code true} if ACDL library should be used. | ||
* @since om.adobe.cq.wcm.core.components.models 12.24.0 | ||
*/ | ||
default boolean isDataLayerSkipAcdlInclude() { return false; }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately isDataLayerClienlibIncluded removes the datalayer.js file not just the ACDL. This may be a bug: when the flag is set to true there is an odd state - some component datalayer interaction happens as before (accordian, text etc), but the components that are caught in a loop in datalayer.js are no longer pushed to the datalayer. In short we get a semi-enabled state. This is the reason (clienlib.config.js): assets: { For the GDL I need to keep datalayer.js. This has led to the ugly approach of "remove DL clientlib and include part of it again" Perhaps it would be better to change the existing functionality so that only the ACDL code is removed by isDataLayerClientlibIncluded? That would allow me to make the whole thing cleaner, and seems more intuitive. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be enough to know that the name of the datalayer is gtag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the datalayer can be called anything or normally dataLayer, regardless of whether GA (gtag) or GTM is used.