Skip to content

Instantly share code, notes, and snippets.

@otarsko
Created December 4, 2019 15:31
Show Gist options
  • Save otarsko/e4f0eff1996871136423ebbc604d6721 to your computer and use it in GitHub Desktop.
Save otarsko/e4f0eff1996871136423ebbc604d6721 to your computer and use it in GitHub Desktop.
Adobe Experience Cloud without AEM | Datalayer component
import React from 'react';
export default class DataLayer extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<></>
)
}
componentDidMount() {
const { pageTitle, pageType, pagePath } = this.props;
{
window.digitalData = {
page: {
pageInfo: {
pageName: pageTitle,
pageType: pageType,
pagePath: pagePath
}
}
}
var event = new CustomEvent('datalayer-complete');
var obj = document.querySelector("body");
obj.dispatchEvent(event);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment