Legacy Knowledge Base
Published Jun. 30, 2025

How to create custom events in Analytics Cloud?

Written By

Rita Schaff

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • I would like to create a custom event, but after checking the official documentation, I am unsure about the steps.

Environment

  • Analytics Cloud
  • DXP 7.0+

Resolution

Please follow these steps to create a simple custom event.

DXP 7.0+

Widget Pages' JavaScript Field

  1. Go to your Liferay instance

  2. Click the Settings gear at the top of the page

  3. Click the Advanced tab

  4. Add the following JavaScript under the JavaScript section
    Analytics.track('eventName',{
    'propertyName': 'valueName'
    });
  5. Replace eventName with a custom name for your event that you can easily identify
    1. You can also replace propertyName and valueName to suit your needs
  6. Visit the page
    → Once you’ve saved this JavaScript code, it will fire every time you visit the page
  7. Check the custom events in Analytics Cloud

DXP 7.0+

Web Content

  1. Go to your Liferay instance
  2. Create a Web Content

  3. Copy and add the following JavaScript code to the Web Content via the Source editor

    <script>
    Analytics.track('eventName',{
    'propertyName': 'valueName'
    });
    </script>
  4. Replace eventName with a custom name for your event that you can easily identify
    1. You can also replace propertyName and valueName to suit your needs
  5. Save this Web Content

  6. Go to a page and add it, e.g. in a Web Content Display fragment
    Note: no content will actually be visible on the page

  7. Visit the page
    → Once you’ve saved this JavaScript code, it will fire every time you visit the page
  8. Check the custom events in Analytics Cloud

DXP 7.3+

Fragment

Create a fragment with the following code in the JavaScript field:

Analytics.track('eventName',{
'propertyName': 'valueName'
});

or this in the HTML field:

<script>
Analytics.track('neweventNameevent',{
'propertyName': 'valueName'
});
</script>

Results

Custom Event Results.png

eventName has been sent 20 times.png

Additional Information

 

Did this article resolve your issue ?

Legacy Knowledge Base