Tracking Google Analytics in CMS with Event Tracking

For the purpose of this post, I am describing how to track dynamic content from a CMS system using Google Analytics and Event Tracking.
I am tying GA Event Tracking to dynamic promotional areas where the content is pulled from a Pull CMS system and rotated in sequence by an AJAX timer.   The rotating content is mixed text with some graphics and links and the client wants to track content impressions and clicks associated with the relative content depending on which content is being displayed. All of the content is loaded into the page simultaneously and an AJAX script rotates what is being displayed.    Tricky part is that we can’t tag anything in CMS because the client changes it fairly often and you can’t embed Javascript into the content areas in this CMS.   Â
The first thing I did was create an Event Tracking Object for this specific dynamic area and loaded it above the dynamic content area. I then created a function that is called when the timer function completes and displays the first content in the cycle. The function dynamically determines which content is being displayed by searching the document for the specific div plus an array generated from the timer. It then appends another function to all the links within that div that loads onclick (Similar to Brian Clifton’s hack for Tracking Outbound Links). The first function also grabs the content title by id and loads it into the GA ET Label and sends the info to GA as the content rotates. The issue I found with this is that when you try to put a JavaScript variable or HTML DOM objects into the Event Tracking label, it makes the GA Event tracking just quit. No errors or anything, the rest of the function just quits which makes it hard to diagnose. A way around is that ASP variables seem to work just fine so by making the javascript that pulls the title equal an ASP variable, I could then substitute the ASP variable into the label. Now every time the content rotates, it fires a GA Event Tracking snippet that creates a “Views†action and associates the content’s title as the label. Â
In order to track clicks, I use the onclick function that was appended to the links within the div that also uses an array to dynamically determine which content we are on in the cycle and fires the GA ETC with “Clicks†as the action and pulls the ASP variable again as the label. Now when I go into GA, I can go to the Event Tracking area, view Objects, select the specific object I want and change the “Detail Level†to “Label†versus action and it displays all the dynamic content pieces within that specific Object. I can then click on each of those and view the “Views†and “clicks†associated with each specific content piece within the given dynamic rotating CMS feature.
I might not have described this process in perfect detail but the logic is somewhat simple, implementation was a little more difficult. Even if the CMS content isn’t being rotated through a timer, you should be able to use a similar approach using Javascript to find the specific div and append either an Event Tracking or pageTracker snippet to track either views or clicks.
If you have any question, feel free to shoot me an email or post it here.
Thanks,
Brad Henry
