Title: Tracking Custom Post Types
Last modified: August 21, 2016

---

# Tracking Custom Post Types

 *  Resolved [FurySting](https://wordpress.org/support/users/furysting/)
 * (@furysting)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/)
 * I have a custom post type which is using the category taxonomy. It shows in my
   categories view on WP but not in the category hit listing on slimstat.
 * This particular custom post type is typically shown with very little of the wordpress
   header. It’s essentially outside of WP but managed from within it. I have the
   javascript file wp-slimstat.js loaded up with the page so I am seeming some tracking
   but I am not getting the category hits.
 * If I wanted to use slimstat for an external page on my site is that javascript
   all I need? And do I need to do something to how it pulls the report for categories
   to get a custom post type to show?
 * I’d be happy to pay for support or buy a pro version of your plugin if there 
   is one.
 * Thanks,
    John
 * [http://wordpress.org/plugins/wp-slimstat/](http://wordpress.org/plugins/wp-slimstat/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [FurySting](https://wordpress.org/support/users/furysting/)
 * (@furysting)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/#post-3956143)
 * Ok answering my own question here…
 * To add your custom post type to the category listing you need to add the ‘taxonomies’
   => array(‘category’) to your register post type initially. Then create a post
   category you want to use for it. and assign that category on post creation.
 * Then add a function to append the query that goes after categories to include
   your custom post type.
 *     ```
       function my_custom_type_in_categories( $query ) {
           if ( $query->is_main_query()
           && ( $query->is_category() || $query->is_tag() ) ) {
               $query->set( 'post_type', array( 'post', 'mw' ) );
           }
       }
       add_action( 'pre_get_posts', 'my_custom_type_in_categories' );
       ```
   
 * So in this case I am adding an action whenever anything in WP goes after the 
   get posts and category or tag is specified amd changing the query set to include
   both post which is the standard and my custom post type of ‘mw’. Doing this I
   now see this custom post type in the reporting on slimstats and the category 
   filter works in all of WP as well. Add all your custom post types to this as 
   members of the array.
 * Happy Coding!
 *  Thread Starter [FurySting](https://wordpress.org/support/users/furysting/)
 * (@furysting)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/#post-3956152)
 * Ok well I was wrong.. The above did the trick for WP and did add it to the listing
   in SlimStats and to the wp_slim_content_info table but it is not adding any content
   id’s and tracking anything. In looking at the slimstat code it looks like you
   are handling custom post types some how with cpt:$post_type but I can’t figure
   it out yet.
 * Any help please?
 *  Thread Starter [FurySting](https://wordpress.org/support/users/furysting/)
 * (@furysting)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/#post-3956268)
 * So do I just ask stupid questions? Am I rude? Or are they to hard to answer?
 * I have not gotten a response from the author on any of my questions and have 
   found a way to do each thing on my own but it would be awesome to at least get
   a response.
 * If anyone would like to know an easy way to pull slimstat into a custom post 
   type that doesn’t use the entirety of wp_footer and adds tracking of individual
   clicks without slowing down the page they are on just ask, I will respond.
 *  Plugin Contributor [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/#post-3956278)
 * Hey there,
 * it’s not a matter of asking stupid questions, but of understanding that this 
   is done for free during my spare time. A little more patience would be greatly
   appreciated.
 * As for your question, you need to call wp_footer to make SlimStat work, at least
   for now. There’s no way around it.
 * Cheers,
    Camu

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Tracking Custom Post Types’ is closed to new replies.

 * ![](https://ps.w.org/wp-slimstat/assets/icon.svg?rev=2832242)
 * [SlimStat Analytics](https://wordpress.org/plugins/wp-slimstat/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-slimstat/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-slimstat/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-slimstat/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-slimstat/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-slimstat/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/tracking-custom-post-types/#post-3956278)
 * Status: resolved