WordPress.org

Ready to get started?Download WordPress

Forums

HubSpot for WordPress
Issue with Tracking Code for Custom Post Types - How to Fix (3 posts)

  1. threegroup
    Member
    Posted 10 months ago #

    Right now, the way the plugin is coded on inc/hs-analytics.php, the plugin will pass along the wrong content type if your website uses custom post types. Lines 26-31 read:

    // Pass along the correct content-type
                if (is_page() || is_front_page()) {
                    echo '_hsq.push(["setContentType", "standard-page"]);'."\n";
                } else {
                    echo '_hsq.push(["setContentType", "blog-post"]);'."\n";
                }

    The fix for this problem is simple, I believe:

    // Pass along the correct content-type
                if (is_page() || is_front_page()) {
                    echo '_hsq.push(["setContentType", "standard-page"]);'."\n";
                } else {
                    echo '_hsq.push(["setContentType", "blog-post"]);'."\n";
                }

    Can you please confirm that this is the case, and if so, update future versions of the plugin accordingly?

    Thank you!

    http://wordpress.org/plugins/hubspot/

  2. threegroup
    Member
    Posted 9 months ago #

    Just noticed I copied and pasted the wrong code. The fix is:

    // Pass along the correct content-type
                if ( !is_singular( 'post' ) ) {
                    echo '_hsq.push(["setContentType", "standard-page"]);'."\n";
                } else {
                    echo '_hsq.push(["setContentType", "blog-post"]);'."\n";
                }
  3. aacook
    Member
    Plugin Author

    Posted 9 months ago #

    We pushed an update earlier this week to address this issue. Is it working for you now? Do you want custom post types to categorize as standard pages or blog posts? Sounds like they should be categorized as standard-page.

    This is the current code snippit:

    if ( is_single () )
                {
                    echo '_hsq.push(["setContentType", "blog-post"]);' . "\n";
                }
                else if ( is_archive () || is_search() )
                {
    
                    echo '_hsq.push(["setContentType", "listing-page"]);' . "\n";
                }
                else
                {
                    echo '_hsq.push(["setContentType", "standard-page"]);' . "\n";
                }

    I'm pretty sure this should dump custom post types into the last else statement and properly categorize them for you.

    Do you mind testing?

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.