• 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!

    https://www.ads-software.com/plugins/hubspot/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter threegroup

    (@threegroup)

    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";
                }
    Plugin Author aacook

    (@aacook)

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Issue with Tracking Code for Custom Post Types – How to Fix’ is closed to new replies.