Issue
- We want to send custom events to Analytics Cloud from our Liferay DXP instance.
- How can we do this?
Environment
- Liferay DXP
- Analytics Cloud
Resolution
For everything else, you can use Custom Events by using any feature of Liferay that supports Javascript, such as
-
Pages' Javascript field
Site Builder → Public Pages → Configuration ⚙ icon → Advanced tab → Javascript field
Any script you enter here will be executed on all the Public pages whenever the page is displayed. -
Web Content Article with a script in the source
- Create a Web Content article with a structure that has a HTML field
- Change the view to the Source view
- Enter your script
- Publish the Web Content article
- Display it on a page
- Whenever the article is displayed, the script is called
-
The Fragment's JavaScript field
Design → Fragments → create a new fragment → JavaScript field
Like web content articles, you need to display the fragment on a page to call the script.
Having the script in the Page JavaScript field is generally the best option. However, using fragments or web content articles could work better depending on what you need.