Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #258687

    Hi there,
    I’m building an asset library with the built-in Portfolio functionality, it’ll be displayed as a grid on the page in question.
    Within this grid will be various file types, PDF’s, images mainly – but my client would like to be able to track how many times a particular asset has been accessed or clicked on.
    I’m using Yoast’s WordPress SEO & Google Analytics plugin’s, so there is some of this basic functionality present already – however I’d ideally like to provide more using Google’s onClick method.
    But I’m not sure how (or if) I can add that to the external URL – is it possible?
    Here’s a screenshot.
    So in this case I’d like to add;
    onClick=“_gaq.push([‘_trackEvent’, ‘Asset Library’, ‘PDF’, ‘Living in Christchurch’]);”
    To the URL in that screenshot above;
    http://www.cdc.org.nz/wp-content/uploads/2014/04/workforce-infographic-poster-a4.pdf
    I’m guessing it’s not as simple as just adding it to the end of this URL?
    Jas

    #259223

    Hi Jason!

    No, you must modify the portfolio shortcode file to add this code. Open up wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/portfolio.php and replace

    
    $output .= "<h2 class='portfolio-grid-title entry-title' $markup><a href='{$title_link}'>".$title."</a></h2>";
    

    with

    
    $track_event = !empty($custom_link) ? "onClick=\"_gaq.push(['_trackEvent', 'Asset Library', 'PDF', 'Living in Christchurch']);\"" : '';
    $output .= "<h2 class='portfolio-grid-title entry-title' $markup><a href='{$title_link}' {$track_event}>".$title."</a></h2>";
    

    If you want to modify the shortcode with a child theme follow the instructions here: https://kriesi.at/support/topic/add-elements-to-visual-composer/#post-242618 but copy the portfolio.php file to your child theme folder.

    Cheers!
    Peter

    #260070

    Hi Peter,
    Thanks for your reply – will this mod allow me to specify different terms for different URL’s?
    In other words, there will be other PDF files which will have different titles (as opposed to ‘Living in Christchurch’) & there will be other file types too, like images & video’s – so I’d like to (ideally) add tracking terms on a URL by URL basis.
    Might be a bit tricky yeah?
    Jas

    #260114

    Hey!

    Yes, this is not easily possible. If you just need to replace “Living in Christchurch” with the portfolio entry title you can use this code instead:

    
    $track_event = !empty($custom_link) ? "onClick=\"_gaq.push(['_trackEvent', 'Asset Library', 'PDF', '{$title}']);\"" : '';
    $output .= "<h2 class='portfolio-grid-title entry-title' $markup><a href='{$title_link}' {$track_event}>".$title."</a></h2>";
    

    However if the text may vary from the portfolio title (= different terms) you would need to modify/customize the theme code. This is something which is beyond the scope of our support forum and would require a freelancer.

    Best regards,
    Peter

    #260182

    Hi Peter,
    Yes – totally understand, can you recommend anyone who may be able to help in this regard?
    Jas

    #260518
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.