chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v3.0
144 stars 36 forks source link

Use the CloseWatcher API to track native modal closes in GA [🟥 awaiting full support] #2269

Open chrisblakley opened 11 months ago

chrisblakley commented 11 months ago

CloseWatcher API documentation:

Here is an example of how to use it:

unnamed

Probably something like this:

const watcher = new CloseWatcher();
watcher.addEventListener('close', function(){
    //Send GA4 event here for element close
});
chrisblakley commented 1 month ago

https://caniuse.com/mdn-api_closewatcher

Screenshot 2024-10-09 at 11 13 11 AM

Waiting for Safari and Firefox support, but would not be hard to add this inside of a conditional that gets removed when it is fully supported, so not necessarily needing to wait...