WordPress.org

Forums

Yet Another Related Posts Plugin (YARPP)
Adding event tracking (19 posts)

  1. Wendihihihi
    Member
    Posted 1 year ago #

    Hi,

    Right now, I'm adding an event tracking code to the file includes/template_thumbnails.php. Line 30-31 look like this:

    $pagetitlee = get_the_title();
    $output .= "<a class='yarpp-thumbnail' href='" . get_permalink() . "' title='" . the_title_attribute('echo=0') . "' onClick='_gaq.push(['_trackEvent', 'YARPP', 'Single Page thumb $pagetitlee', 'Clicked',, false]);'>" . "\n";

    It works well, but the disadvantage is that with the next plugin update I have to add it again.

    Is there a better way of doing this?

    Thanks

    https://wordpress.org/plugins/yet-another-related-posts-plugin/

  2. Θεοφάνης
    Member
    Posted 8 months ago #

    Hi,

    I'd like to add support for Piwik campagn tracking rather than GA events. Would you know how to deal with that ? All I want to do is add "?pk_campaign=YARPP" to the URLs YARPP suggests.

    Thanks !

  3. Wendihihihi
    Member
    Posted 8 months ago #

    Hi,

    You want to do this manually? It also depends what settings you use and on what pages. Is it only for the posts?

  4. Θεοφάνης
    Member
    Posted 8 months ago #

    Yes, I'd like to do this for the suggested links at the end of the posts only. I don't mind adding a snippet of code manually every once and a while when they update YARPP.

    Thanks for your help !

  5. Wendihihihi
    Member
    Posted 8 months ago #

    Line 31, includes/template_thumbnails.php.
    $output .= "<a class='yarpp-thumbnail' href='" . get_permalink() . "?pk_campaign=YARPP' title='" . the_title_attribute('echo=0') . "'>" . "\n";

  6. Θεοφάνης
    Member
    Posted 8 months ago #

    Hi there, thanks for helping !

    I did implement the hack you suggested, but it doesn't seem to work. My YARPP suggested links do not show up with the ?pk_campaign=YARPP parameter.

    Do you have any idea why ?

    Thanks again !

  7. Wendihihihi
    Member
    Posted 8 months ago #

    Could you post the website's url or send it to me. Maybe your way of using YARPP isn't the same as mine.

  8. Θεοφάνης
    Member
    Posted 8 months ago #

    Sure, the website is http://ths.la

    Thanks !

  9. Wendihihihi
    Member
    Posted 8 months ago #

    I have looked, but can't find the YARPP thumbnails or is it the text Vous Avez Aimé Cet Article etc.

    Yeah, it's the text. The solution above was meant for the thumbnails version. I'll look at it tomorrow.

  10. Θεοφάνης
    Member
    Posted 8 months ago #

    All right, got it ! You're not seeing them, because I'm not using them :) I'm using the list feature to show related links.

    I guess I have to edit the appropriate file, correct ?

  11. Wendihihihi
    Member
    Posted 8 months ago #

    Yes, you are right, but I don't know off head which file it is. I'll check tomorrow if you have managed yourself otherwise I'll find the right file.

  12. Θεοφάνης
    Member
    Posted 8 months ago #

    I this the file I need to edit is yet-another-related-posts-plugin/yarpp-templates/yarpp-template-list.php

    But I think I'm messing up with the syntax.

    <?php
    /*
    YARPP Template: List
    Description: This template returns the related posts as a comma-separated list.
    Author: mitcho (Michael Yoshitaka Erlewine)
    */
    ?><h3>Related Posts</h3>
    
    <?php if (have_posts()):
    	$postsArray = array();
    	while (have_posts()) : the_post();
    		$postsArray[] = '<a href="'. get_permalink() . .?pk_campaign=YARPP'" rel="bookmark">'.get_the_title().'</a><!-- ('.get_the_score().')-->';
    	endwhile;
    
    echo implode(', '."\n",$postsArray); // print out a list of the related items, separated by commas
    
    else:?>
    
    <p>No related posts.</p>
    <?php endif; ?>

    Thanks again for your assistance !

  13. Wendihihihi
    Member
    Posted 8 months ago #

    I would go for this one

    $postsArray[] = '<a href="'.get_permalink().'?pk_campaign=YARPP" rel="bookmark">'.get_the_title().'</a><!-- ('.get_the_score().')-->';

  14. Θεοφάνης
    Member
    Posted 8 months ago #

    Hi there, so here I am, back at the office.

    I still can't make it work, I think I'm editing the wrong file. Could you check and tell me what's the file I need to modify ?

    Thanks a million !

  15. Wendihihihi
    Member
    Posted 8 months ago #

    Hi. How do you add the links to your post? Do you choose at the Display options the option Post and the button List or do you choose Custom and go for the List option?

  16. Θεοφάνης
    Member
    Posted 8 months ago #

    Hi there, not sure I even understand your question.

    I've left all the default settings, which use the list option.

    Here's how the setup looks like : http://i58.tinypic.com/2888l1i.png

  17. Wendihihihi
    Member
    Posted 8 months ago #

    Ow, in that case you should be in template_builtin.php, line 43. Should look like
    '<a href="'.$link.'?pk_campaign=YARPP" rel="bookmark" title="'.$tooltip.'">'.

  18. Θεοφάνης
    Member
    Posted 8 months ago #

    Alright, this works like a charm !

    Thank you very much for your assistance, I owe you a beer :)

  19. Wendihihihi
    Member
    Posted 8 months ago #

    No problem. I'll drop by when I'm in the neighborhood ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yet Another Related Posts Plugin (YARPP)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic