For anyone who is trying to add click tracking to user events with an accordion for Google Analytics:
The accordion does not write IDs for each accordion page; it writes a “data-fake-id” so the toggle can open on load, but won’t work when it comes to tracking the event.
I figured out how to add the code for Google Tracking. Open Enfold/config-templatebuilder/avia-shortcodes/toggles.php
Scroll to line 215. Find:
$output .= ' <p data-fake-id="#'.$toggle_atts['custom_id'].'" class="toggler '.$titleClass.'" '.$markup_title.'>'.$toggle_atts['title'].'<span class="toggle_icon">';
Replace with:
$output .= ' <p data-fake-id="#'.$toggle_atts['custom_id'].'" id="track-'.$toggle_atts['custom_id'].'" class="toggler '.$titleClass.'" '.$markup_title.'>'.$toggle_atts['title'].'<span class="toggle_icon">';
Using the plugin WP GA Events by Yuval Oren, add the element name “track-toggle-id-1” with the type set to “ID”
This will track your event action. You can inspect the element to determine the exact element name for all of your tracking events.
If you eliminate the track- before $toggle_atts, it will use the assigned custom ID. This will cause the accordion to jump around on the screen while the user is interacting with the page. I’d keep track- (or some other pre text) to keep the accordion functionality intact.
This took me a while to figure out – hopefully it helps someone out!
Hi @kristenangel,
Thank you very much for sharing that, I’m sure it will be useful for the community!
Best regards,
Rikard