'Create JavaScript event triggers for Google Analytics 4

Articulate Storyline is a software for creating interactive learning courses. I can execute JavaScript triggers in storyline files to track button clicks with Google Analytics 4.

I added the following code to the button, but it didn't work.

ga('send', 'event', 'Button', 'click', 'Next Button');

The code was working fine with the old version of Google Analytics(UA). Many designers are looking for the answer. We need developer's help. :) Any advice would be appreciated.



Solution 1:[1]

I think this is covered here: https://support.google.com/analytics/answer/11147304

It looks like you can do

<script>
  gtag("event", "publish", {role: "Writer"});
</script>

Edit: additional information in the documentation here; https://support.google.com/analytics/answer/11403294?hl=en

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1