You could add data-
attributes to your ad link if you are using HTML5:
<a href="example.com" class="someclass" data-adposition="Banner Ad - Top" data-adnamesize="Ad Title - (588x88)" data-advalue="1.00" ><img src="example.com/ads/ad_588x88.jpg" alt=""></a>
Then add a new tag in Google Tag Manager for catching clicks on this kind of links (identified by "someclass" as an example). Tag name
: Whatever-you-want-to-name-it; Tag Type
: Custom HTML Tag
.
Using JQuery you can extract data-
attributes and pass them as parameters to ga
function. Insert this snippet into HTML
textbox. Obviously, you'll need to adjust the snippet as you need, based on what you use as class
and data-
attributes names.
<script type="text/javascript">
$( document ).ready(function() {
$( document ).delegate( "a.someclass", "click", function() {
try{
ga('send',
'event',
$(this).data('adposition'), //Event Category
'click', //Event action
$(this).data('adnamesize'), //Event Label
$(this).data('advalue'), //Event value
{'nonInteraction': 1}
);
}catch(err)
{
//do something if you need
}
});
});
</script>
Then add a Firing Rule
that fires on every single page of your site, assuming you have those kind on links every where. Such rule should be like this
{{url}} matches regex .*
Update: Using GTM Link Click Listener
Assuming your links have data-attributes as my example above, you can do something like this:
Set up GTM Link Click Listener###
Add a new Tag.
Set Tag Name to whatever you want, maybe Link Click Listener
.
Set Tag Type to Link Click Listener
.
Add a Firing rule for all pages.



Set up click event tracking for your ad links
Add a new Tag.
Set Tag Name to whatever you want, maybe Ad Links Click
.
Set Tag Type to Google Analytics
=> Universal Analytics
or Classic Google Analytics
, depends on what version you're using.
Insert your Web Property Id.
Set Track Type to Event
; for Event Tracking Parameters you'll need to add macros to grab info from your ad links and set them into Event's parameters.
For event Category:
Click on the brick icon, then select New macro
.
Set Macro Name to something like Ad Link Position
.
Set Macro Type to Custom Javascript
.
Insert this code into Custom Javascript textbox:
function(){
return {{element}}.dataset.adposition;
}
For event Action set whatever you want, maybe click
.
For event Label:
Click on the brick icon, then select New macro
.
Set Macro Name to something like Ad Link Name - Size
.
Set Macro Type to Custom Javascript
.
Insert this code into Custom Javascript textbox:
function(){
return {{element}}.dataset.adnamesize;
}
For event Value:
Click on the brick icon, then select New macro
.
Set Macro Name to something like Ad Link Value
.
Set Macro Type to Custom Javascript
.
Insert this code into Custom Javascript textbox:
function(){
return {{element}}.dataset.advalue;
}
Maybe you don't want clicks to those ad links count as an interaction, then set event Non-interaction to true
.


And here comes the magic, chain Ad Links Click
to Link Click Listener
:
Add a new Firing Rule for Ad Links Click
tag.
Set Rule Name to something like Ads GTM Link Click Event
.
Add a new Condition set {{event}}
equals
gtm.linkClick
.
Add a second Condition set {{element classes}}
equals
someclass
.
