Google Analytics Event Tracking for Essential Grid

Track your Essential Grid clicks with Google Analytics

Quick Tip:

Already have your GA tracking code installed and your slider links setup? Skip to step #3.

1. Setup your Google Analytics account for your site

If you’re reading this article, chances are you already have Google Analytics (GA) setup for your site. But if not, here are a few good places to start for setting up GA for your WordPress site:

Getting Started with Google Analytics:
https://support.google.com/analytics/answer/1008015?hl=en

Where to find your Tracking Code:
https://support.google.com/analytics/answer/1032385?hl=en

Setting up your Tracking Code:
https://support.google.com/analytics/answer/1008080?hl=en

WordPress Plugin to connect your GA Account to your site:
https://wordpress.org/plugins/google-analytics-for-wordpress/

https://www.themepunch.com/essgrid-doc/grid-item-links/

3. Add the following script to your grid’s API/JavaScript section.

This code does not need to be modified (straight copy and paste)

/* listen for clicks for outbound links, lightbox, and filter buttons */
jQuery('body').on('click', '.esg-grid a, .esg-filterbutton', function() {
 
    var $this = jQuery(this),
        data  = '';
 
    /* if click is outbound link or lightbox */
    if($this.is('a')) {
 
        /* if clicked item is lightbox link */
        if($this.hasClass('esgbox')) data += 'Lightbox: ';
 
        data += $this.attr('href');
 
    }
    /* if click is filter button */
    else {
 
        data += 'Filter: ' + $this.text();
 
    }
 
    /* send event data to Google */
    __gaTracker('send', 'event', 'outbound', 'click', data, {'transport': 'beacon'});
 
}); 
Google Analytics Event Tracking for Essential Grid

Further Resources for Web Design and Development Enthusiasts

Alright! We've embarked on quite an adventure exploring the realms of this topic. But why stop there? The world of web design and development is vast, and there's always more to learn and discover. Let's dive into some resources that'll keep your knowledge fresh, your skills sharp, and your passion ignited:

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!