Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtsternberg/918238ff899c2762b41b to your computer and use it in GitHub Desktop.
Save jtsternberg/918238ff899c2762b41b to your computer and use it in GitHub Desktop.
Modify the google analytics request params in the google top content plugin
<?php
/**
* Change metric from 'ga:pageViews' for top-content widget and shortcode
*
* @link https://ga-dev-tools.appspot.com/query-explorer/ Google's Query Explorer for more info
*
* @param array $params Array of request params
*
* @return array Modified array of request params
*/
function gtc_modify_request_metric( $params ) {
$params['metrics'] = 'ga:uniquePageviews';
return $params;
}
add_filter( 'gtc_analytics_top_content_shortcode_request_params', 'gtc_modify_request_metric' );
add_filter( 'gtc_analytics_top_content_widget_request_params', 'gtc_modify_request_metric' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment