Analyticator Shortcodes

Below, you’ll find a detailed guide on how to add the Analyticator Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Analyticator Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Analyticator Plugin and the shortcodes it provides:

Plugin Icon
Analyticator

"Analyticator is a WordPress plugin that integrates your website with Google Analytics. With the google-analyticator plugin, you can easily track and view your site metrics in real-time."

★★★✩✩ (126) Active Installs: 80000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [analytics]
  • [analytics-counter]

Analyticator [analytics] Shortcode

The Google Analyticator shortcode is a powerful tool that enables the display of Google Analytics data within your WordPress site. This shortcode calls the ‘ga_analyticator_shortcode’ function, which loads the Google Analytics Summary widget. The widget’s output is then wrapped in divs to replicate the structure of the admin dashboard widget. The result is a clean, integrated display of your Google Analytics data right on your website.

Shortcode: [analytics]

Examples and Usage

Basic example – A simple usage of the Google Analyticator shortcode to display the Google Analytics Summary widget on a page or post.

[analytics]

PHP Function Code

In case you have difficulties debugging what causing issues with [analytics] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'analytics', 'ga_analyticator_shortcode' );

Shortcode PHP function:

function ga_analyticator_shortcode( $atts ) {
	# Include the Google Analytics Summary widget
	require_once('google-analytics-summary-widget.php');

	ob_start();

	$google_analytics_summary = new GoogleAnalyticsSummary(TRUE);
	// Wrap it with these divs to mimic the admin dashboard widget structure.
	echo '<div id="google-analytics-summary"><div class="inside">';
	$google_analytics_summary->widget();
	echo '</div></div>';

	return ob_get_clean();
}

Code file location:

google-analyticator/google-analyticator/google-analyticator.php

Analyticator [analytics-counter] Shortcode

The Google Analyticator plugin shortcode, ‘analytics-counter’, is designed to display Google Analytics stats on your WordPress site. This shortcode calls the GoogleStatsWidget function, which retrieves the Google Analytics data. It encapsulates the output in a buffer, ensuring a clean return, devoid of any unwanted data. The TRUE parameter, when passed, activates the widget.

Shortcode: [analytics-counter]

Examples and Usage

Basic example – The basic usage of the ‘analytics-counter’ shortcode is to display the Google Analytics stats on your WordPress site. It doesn’t require any additional parameters.

[analytics-counter /]

PHP Function Code

In case you have difficulties debugging what causing issues with [analytics-counter] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'analytics-counter', 'ga_analyticator_counter_shortcode' );

Shortcode PHP function:

function ga_analyticator_counter_shortcode( $atts ) {
	# Include Google Analytics Stats widget
	require_once('google-analytics-stats-widget.php');
	ob_start();

	$google_analytics_widget = new GoogleStatsWidget(TRUE);

	return ob_get_clean();
}

Code file location:

google-analyticator/google-analyticator/google-analyticator.php

Conclusion

Now that you’ve learned how to embed the Analyticator Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *