Image carousels and Google Analytics

Hi all.

We have an image carousel on our homepage, and we swap the images out pretty frequently. It’s a custom widget–the widget has 7 “slots” for images and the page URL it links. 

We’ve been tracking clicks with URL parameters, but need to change our process. I’m thinking event tracking, but am not sure how to give each banner a unique label. We want our stats to reflect the banner content, so it will show a click on “referral-program” or “seminar,” not banner position 1 or 2.

Could I add a label field to my widget, and then code the widget to do something like _gaq.push([‘_trackEvent’, ‘homeBanner’, ‘click’, ‘$label’]); on click?

Hi Lisa, 

That’s a really great question! I think your idea for a solution sounds feasible.

You can add additional fields in the widget using the widget builder and embed the velocity label variables in the Display HTML output. Also, using embedded script tags in the Display HTML section you can use the velocity label variables in javascript click handlers as well. 

In the 5.3 release of Percussion, fields added in the Widget Builder are no longer required by default, so it would be prudent to add some logic to your code to handle blank or improperly entered label values, depending on how you configure them with your tracking.

Fields can be set to “Required” by using the Percussion CM1 Workbench in the SDK available on the downloads page.  

Hopefully, that’s not too general advice for you, it’s hard to be more specific without looking at the code.

Let me know how you make out and if you run into any snags on this!

Best,
Piotr

Thanks, Piotr!

Widgets I’ve recently created or edited still show every field as required. That shouldn’t be the case in 5.3?

following

That’s correct, Lisa, in 5.3+ all Widget Builder fields are no longer required, however, there is a bug logged on the Asterisk that still appears before the field names. That bug should be resolved in a future update. 

Though the asterisk still appears before the field names, they are not all required to be filled in before saving the widget. 

-Piotr

Looks like it is working! We are entering the image path, page URL, and label in the custom widget, and a click event is being sent to GA.

Happy to hear you got it worked out!