WordPress.org

Forums

Google Analytics by Yoast
trackEvent Download - Not working on Custom Post Type (2 posts)

  1. cdodge
    Member
    Posted 1 year ago #

    Hello,

    I'm using the plugin and everything works just fine including tracking download events throughout my site in my google analytics, however the exception seems to be a custom post type of mine.

    The links I am trying to track are downloadable PDFs that I import using a custom post type field. I then call the medias URL in my template as a link.

    I call the link as such -

    <p><b>Download PDF:</b> <a href="<?php echo $url; ?>"><?php echo the_title(); ?></a></p>

    With the resulting link -

    <p><b>Download PDF:</b> <a href="http://document.pdf">Document Title</a></p>

    I'm unsure as to why the trackEvent code is not being attached to this download link?

    https://wordpress.org/plugins/google-analytics-for-wordpress/

  2. ericthibeault
    Member
    Posted 5 months ago #

    Hi, just want to know if you've found a solution because I've got the same issue: If I insert a pdf file in a content box, the onclick event is injected but If I create a link to... the same pdf, from an archive of a custom post type (archive-articles.php for cpt articles), no onclick is being injected.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Analytics by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic