Fire script when triggering off-canvas modal

Hi,

I have an off-canvas model on my site containing the main menu (behind a hamburger). I would like to understand which % of visitors actually find/use the menu. I can trigger an event in Google Analytics using javascript. I am not a star in Javascript - what kind of script should I use to listen to the event opening the modal?

Thanks, Paul

Hi Paul,

Thanks for reaching out.

You mean an event tracker? I could only provide the idea and assume you’re tracking the click on hamburger menu instead of the menu links. With that, you can add unique ID to your off canvas modal (it depends on you which ID you prefer),

I use the ID track_this_for_me, then what you need to do is add this script to your global custom javascript, or just in your header custom javascript.

jQuery ( document ).on('click', '#track_this_for_me-anchor-toggle', function() {

//your tracking code here

} );

You need to replace the line //your tracking code here with your tracking code, then replace #track_this_for_me-anchor-toggle with your preferred ID (don’t relace the part -anchor-toggle. (eg. #{your-id-here}-anchor-toggle).

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.