Sarathlal N

Add Google analytics on Anchor CMS

Have you ever tried to add Google analytics script on Anchor CMS. I have a simple & efficient way to do it with site variable in Anchor CMS.

The anchor CMS is a light weight, fast & minimal open Source blog engine written in PHP. It have some amazing options and now we use one of it, site variable to add Google analytics code on Anchor CMS.

The site variable is a option to add variables for site wise in Anchor CMS. We can access its value as a site meta in any where in our template files. We use this option to add our analytics script in our theme’s header or footer.

Before further reading, I consider that you have your Google Analytics code with you. If else, you want to make a analytics script for your site from Google analytics official website.

Step 1: Add a new site variable in admin area of Anchor CMS.

For example, value for g_analytics, my site variable is look like below one.

<script type="text/javascript">
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;

The g_analytics is the name for my site variable & you can use any unique name for it.

Step 2: Now we want to use this snippet in our theme files.

In feature, if you want to edit your Google analytics code or customize it, just go to site variable option in admin end & edit your script in value field. This is the biggest advantage of this method because our analytics script is automatically updated without any editing in theme files.

Recent Posts

  1. Redirect single pages of post type in to post type archive page - WordPress
  2. Get details about available image sizes - WordPress
  3. Change shipping and billing address title - WooCommerce
  4. Add phone number to the output of the addresses on the "My Account" page - WooCommerce
  5. Conditional tags for order thank you page - WooCommerce

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about them, please get in touch.