Tracking Banner CTR (Click Through Rate)
With actionable knowledge of the banner CTR produced by your traffic acquisition campaigns you can understand what is working, what is not, and what seems suspicious.
If your buying from a new source and the CTR is through the roof you need to know how to correct this as quickly as possible. As of today there are not too many ways to accomplish this task and unless your using Google Analytics along with one of the Google Ad Networks and have them speaking nicely together. In the real world people are not using Google exclusively and the need to track CTR in a more generic way exists for many of us.
Using the following code snippets you can track CTR with any advertising network that you use. Simply adapt the code to find the correct html elements and voila, your done. This code was originally written to find Google DFP tags but can be changed to locate anything that javascript has access to. Basically we are just binding a mouseover and mouseout function to each element that we are targeting. If the mouse enters or exits the container then we mark it as such. If a window blur event occurs while the mouse is inside a target container then we assume a click happened and send an event to Google Analytics. Now from within Google Analytics we can set the event up as a goal and track CTR percentages and report on them using any available dimension.
This can be easily adapted for any javascript framework, any ad network, and any analytics platform. This method can produce some false positives but is great enough to keep you informed of whats happening with your sources. You can't bill on this information but we do find it to be 98% accurate in our use cases.
The Code
var _isOverElement = false;
var _elementID = '';
$(document).ready(function() {
$('div[id^=div-gpt]').each(function() {
$(this).bind({
mouseover: function() {
_isOverElement = true;
_elementID = $(this).attr('id');
},
mouseout: function() {
_isOverElement = false;
_elementID = '';
}
});
});
});
$(window).blur(function() {
if (_isOverElement) {
ga('send', 'event', 'banner', 'click', _elementID, 1);
}
window.focus();
});
If you need any help or have any questions please contact us and let us know.