Adding Google Tag Manager To AcyMailing Popup Buttons
We recently received a request for a trial web page. The Joomla 2.5 page needed click capture for a number of the page elements. One of the page components that needed the mouse click event captured was an Acymailing (version: 4.1.0) newsletter module. The module had been configured to use the mooTools popup for signup.
For this it was necessary to change the one of the Acymailing files on the server.
/public_html/modules/mod_acymailing/tmpl/popup.php
An alteration to the following line:
<a <?php echo $link; ?> id=”acymailing_togglemodule_<?php echo $formName; ?>” href=”<?php echo $href;?>”><?php echo $mootoolsButton ?></a>
to
<a <?php echo $link; ?> id=”acymailing_togglemodule_<?php echo $formName; ?>” onclick=”dataLayer.push({‘event’: ‘subscribe-link-click-<?php echo $module->id; ?>’});” href=”<?php echo $href;?>”><?php echo $mootoolsButton ?></a>
The additional entry: onclick=”dataLayer.push({‘event’: ‘subscribe-link-click-<?php echo $module->id; ?>’});” registers that on a mouse click the dataLayer will will be ‘pushed’ with the type of element, in this instance ‘event’, and the name of the element, in this instance ‘subscribe-link-click-<?php echo $module->id; ?>’.
The more familiar of you out there may ask why we have used the additional php code to define the element: <?php echo $module->id; ?>. Good question and I am glad that you asked. This code will uniquely define the newsletter element when multiple newsletter subscriptions are defined in a page, as was the situation with our work request. I initially tried by using the <?php echo $formName; ?> element, but this is unique for each page load, and therefore of no use, as far as I could see, within Google Tag Manager.
Please let us know if you have any questions, and happy coding!
If you haven’t installed AcyMailing yet, you can get it directly from the developers (Acyba) by clicking on the image below:
Thomas
Hi,
Thanks for this trick. I’m trying to do the same for a Joomla 2.5 website but I don’t use a popup for the signup. Where you I place the code then?
Cheers,
Thomas
Sara Thornton
Hi Thomas,
Thanks for your post. If you can find the php file that relates to the signup that you are using, back up the file, and then find the button code and follow a similar pattern to the code addition mentioned above, then that should work.
Let me know how you get on?
Thanks,
Sara