Skip to main content

Try our fabulous 5 Day SEO Challenge Let's Go

Adding Google Tag Manager To AcyMailing Popup Buttons

Google Tag Manager

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:


jj

Mantra: live as much as you can in the short time we're on this awesome planet, but try to leave our shared home as nice as when you arrived, perhaps even nicer.

Comments (2)

Leave a Reply

Your email address will not be published. Required fields are marked *