1

A site I'm working on allows a client to place banner ads in various locations using a 'sponsors' channel in EE. The channel is fairly simple and has fields for the banner image itself, a target URL etc.

I would like to record both impressions and click throughs from the banners to the target URLs. In a perfect world the banners when displayed will link directly to the sponsors target URL so that they can gain some SEO value from the link.

Recording banner impressions is easy, I can just use the native 'views' parameter to do this:

{exp:channel:entries track_views="one" ...

However, how can I ensure that a 'click' on a banner also records a 'view' to the 2nd view column for that entry before the user is redirect to the target URL in the href?

4
  • Sounds like you need to do this in the CP but you could do it easily with Google Analytics Event tracking. It's easy to set up (a tweak to the tracking code and a simple bit of JS/jQuery to fire off events) and you can get quite granular. Plus, if they're using Analytics you can gauge against other metrics too. Very handy. – foamcow Jun 11 '14 at 9:18
  • Thanks, I should add that I need to be able to return the view and click counts in a template on the front end. i.e. how many clicks has my sponsor banner had 'type thing'. :) – Nathan Pitman Jun 11 '14 at 11:55
  • Google's reporting API? :) Creating more work for you :) – foamcow Jun 11 '14 at 13:19
  • Ha, yes... definitely creating more work for me. Something I might take a look at though, didn't realise they had an API. :) – Nathan Pitman Jun 12 '14 at 12:23
1

Fudge it by by creating a tracker template?

You mention your banners are in a channel entries, so I assume the image, url, etc are all stored there. Instead of using the actual URL for the banner href, use /adverts/tracker/[entry_id]

Create a template group called adverts and a template called tracker, inside this template it does a channel entries tag pair utilising {segment_3} for the entry_id and track_views="two", pulling in the correct URL and redirecting. Utilise either EE redirect tag, meta refresh or JS. Although all would create a 301 issue and not good for SEO.

A better alternative that suits your brief a bit better is to keep the correct final URL in the href tag and use a data-id attribute to the a tag on the banner set with the entry_id value, and catch the click with JQuery. This then uses the data-id attribute to append the entry_id to a fixed template URL (tracker template as described above), calling this URL (tracker template) in an Ajax call but without any redirects and stores the click to the entry ID. Once the above page is rendered and click impression stored, the Ajax returns and you continue with the click through to the sponsor.

The ideal solution would be to create a module with an ACTion url that could be called on Ajax and save the track, but more time overhead than creating a template to do it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.