Google Analytics Events for li items -


i'm trying add google analytics click tracking events li list items (active thumbnails) used in responsive grid application, , can't working. i've researched here , in google developer forums without success. i'm sure there simple i'm doing wrong. have latest ga script code installed (page view analytics working fine). here code sample:

<ul>     <li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >     <a href="#" onclick="_gaq.push(['_trackevent', 'gridlinks', 'click', 'outlander clicks 1']);"></a></li>     <li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>     <li data-thumbnail-text >         <p class="largelabel" >diana gabaldon -  outlander series</p></li> </ul> 

hope can help. feel free suggest better way of doing it.

update: i'm still digging, , ga code has been updated universal analytics , looks this:

<ul>     <li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >        <a href="#" onclick="ga('send', 'event', 'thumbnail', 'click', 'outlander clicks 1');"></a></li>     <li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>     <li data-thumbnail-text >         <p class="largelabel" >diana gabaldon -  outlander series</p></li> </ul> 

update 2: tried opening outbound link target in new page see if lack of callback might problem. no success. following 2 views of code, 1 contained inside li outbound link, other in separate li same parent ul. neither works. know syntax correct? thx.

example 1: href in it's own li:

<ul>     <li><a href="#" onclick="ga('send', 'event', 'thumbnail', 'click', 'outlander clicks 1');"></a></li>     <li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_blank" ></li>     <li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>     <li data-thumbnail-text >         <p class="largelabel" >diana gabaldon -  outlander series</p></li> </ul> 

example 2: href inside outbound link li:

<ul>     <li data-type="link" data-url="http://www.starz.com/outlandercommunity/home.html" data-target="_blank" >         <a href="#" onclick="ga('send', 'event', 'thumbnail', 'click', 'outlander clicks 2');"></a></li>     <li data-thumbnail-path="outlander_files/thumbnails/community1.png" ></li>     <li data-thumbnail-text >         <p class="largelabel" >starz:  outlander community</p></li> </ul> 

the syntax using event tracking uses classic ga syntax (_gaq.push), if using universal analytics (assuming mean using "latest ga script code"), syntax needs updated:

onclick="ga('send', 'event', 'gridlinks', 'click', 'outlander clicks 1');" 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -