onclick JavaScript

WordPress Plugin Grid Gallery With Custom Links – onclick JavaScript

You can track clicks on outbound links or just about any type of interaction within a Grid Gallery.


How to add JavaScript to onclick event

  • Grid Gallery > open WordPress Gallery
  • Select an image
  • Go to Options > onclick JavaScript
  • Enter the script

The script you enter will be inserted into onclick event of the image and Caption 1.

Sample Google Analytics script:

_gaq.push(['_trackEvent', 'Out', 'Click', 'Value']);
<a onclick="_gaq.push(['_trackEvent', 'Out', 'Click', 'Value']);" href="http://www.x.com/">Caption1</a>



How to track events with Google Analytics

Add track event script

_gaq.push(['_trackEvent', 'action', 'opt_label', 'opt_value', 'opt_noninteraction']);

See Tracker Guide for more info:


I can’t find onclick JavaScript setting

Install and activate our free plugin Media Library Custom Fields. This plugin provides the onclick JavaScript field you are looking for. The field is hidden by default.  Make it visible.

See documentation for more info: https://abcfolio.com/wordpress-plugin-media-library-custom-fields/