Tracking Code Manager Shortcode

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

Before starting, here is an overview of the Tracking Code Manager Plugin and the shortcodes it provides:

Plugin Icon
Tracking Code Manager

"Tracking Code Manager is a handy WordPress plugin, designed to manage and keep track of all your website's tracking codes. It simplifies the process of adding, updating, or deleting tracking codes. Ideal for SEO optimization."

★★★★✩ (58) Active Installs: 100000+ Tested with: 6.2.3 PHP Version: 5.6
Included Shortcodes:
  • [tcmp]

Tracking Code Manager [tcmp] Shortcode

The Tracking Code Manager (TCM) shortcode is a powerful tool that fetches and returns a specific tracking snippet. This shortcode, when inserted into a post or page, calls the ‘tcmp_shortcode’ function. It retrieves the tracking code associated with the ID provided in the shortcode attributes. If no valid ID is given, it returns an empty string, ensuring no errors occur. This allows for precise tracking code management within your WordPress site.

Shortcode: [tcmp]

Parameters

Here is a list of all possible tcmp shortcode parameters and attributes:

  • id – The unique identifier for the tracking code snippet.

Examples and Usage

Basic example – A simple usage of the shortcode to fetch a tracking code snippet by its ID.

[tcmp id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'tcmp', 'tcmp_shortcode' );

Shortcode PHP function:

function tcmp_shortcode( $atts, $content = '' ) {
	global $tcmp;
	extract( shortcode_atts( array( 'id' => false ), $atts ) );

	if ( ! isset( $id ) || ! $id ) {
		return '';
	}

	$snippet = $tcmp->manager->get( $id, true );
	return $snippet['code'];
}

Code file location:

tracking-code-manager/tracking-code-manager/includes/core.php

Conclusion

Now that you’ve learned how to embed the Tracking Code Manager Plugin shortcode, 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 *