Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm changing my WordPress permalinks from




Is is possible to make Google Analytics to continue gathering the posts data correspondingly?

share|improve this question
up vote 2 down vote accepted

Yes, it is possible, but you would need to alter the way your Google Analytics tracking script behaves and, in the long run, your analytics data would not map directly to your site's URI structure (which may compromise the usefulness of your analytics reports).

Your revised Google Analytics snippet would look something like this:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);

<?php if ( is_single() ): ?>
  _gaq.push(['_trackPageview', '/<?php $cat_list = get_the_category(); $cat = $cat_list[0]; echo $cat->slug; ?>/<?php the_ID(); ?>']);
<?php else: ?>
<?php endif; ?>

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


As stated above, you probably won't be happy with the results in the long run if you implement this workaround, however, you may want to familiarize with the WordPress Codex and the WordPress StackExchange site if you would like to learn more about modifying how your blog behaves.

The example above also makes use of Virtual Pageviews in Google Analytics.

share|improve this answer
Well, so I am going to follow your advice and group the data in Google Analytics. Thank you, guys! – pelegrini May 25 '12 at 23:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.