• 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://www.ads-software.com/plugins/yet-another-related-posts-plugin/

Viewing 15 replies - 1 through 15 (of 18 total)
  • 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 !

    Thread Starter Wendihihihi

    (@wendihihihi)

    Hi,

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

    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 !

    Thread Starter Wendihihihi

    (@wendihihihi)

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

    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 !

    Thread Starter Wendihihihi

    (@wendihihihi)

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

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

    Thanks !

    Thread Starter Wendihihihi

    (@wendihihihi)

    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.

    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 ?

    Thread Starter Wendihihihi

    (@wendihihihi)

    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.

    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 !

    Thread Starter Wendihihihi

    (@wendihihihi)

    I would go for this one

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

    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 !

    Thread Starter Wendihihihi

    (@wendihihihi)

    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?

    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 : https://i58.tinypic.com/2888l1i.png

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Adding event tracking’ is closed to new replies.