Folgenden Code have ich bei mir im header.php:
<script type=“text/javascript“>// <![CDATA[
(function(i,s,o,g,r,a,m){i[‚GoogleAnalyticsObject‘]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script‘,’https://www.google-analytics.com/analytics.js‘,’ga‘);ga(‚create‘, ‚UA-37283245-1‘, ‚auto‘);
//ga(’send‘, ‚pageview‘);(function($, undefined){
/**
* Add click event handler to an element / multiple elements
* which pings Google Analytics when the element is clicked.
* Requires jQuery.
* Google reference: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
*
* Mark Howells-Mead / permanenttourist.ch
* Since 24/03/16
*/$.fn.extend({
ga_trackElementClick: function() {
$(this).each(function(){
$(this).on(‚click.GA‘, function(){
try {
ga && ga(’send‘, {
hitType: ‚event‘,
eventCategory: ‚Posts recent‘,
eventAction: ‚clicked‘,
eventLabel: $(this).attr(‚href‘)
});
}catch(e){}
});
});
return this;
}
});$(‚welcomeAccordion.panel-title a‘).ga_trackElementClick();
})(jQuery);
// ]]></script>