• foxymonkey

    (@foxymonkey)


    It’s not unusual for links to be connected to a website goal. For example each click can be reported to facebook saying “£0.06 were generated”.

    But Easy affiliate links does not offer support to inject a function call in the onclick events. So what I ended up doing is removing the [eafl] where I need it which messes up its statistics.

    It would be great to have this option. Any plans to add it in the near future?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Brecht

    (@brechtvds)

    The shortcode is actually not required for the statistics. As long as the link you have (with any custom code attached you want) goes to the shortlink (the /recommends/ URL) it will be counted towards clicks.

    With jQuery it would also be possible to attach a custom event to the earl-link class.

    Kind regards,
    Brecht

    Thread Starter foxymonkey

    (@foxymonkey)

    Thanks for the quick reply Brecht, I appreciate that!

    With jQuery however, you cannot differentiate between 2 different links on the same page. This is because all eafl links have the same “eafl-link” class but no IDs. This is a problem when I’m writing comparison articles for example and want a different affiliate link for different products.

    The only alternative I have now is to remove the eafl-link and replace it with the tag with onclick events which defeats the purpose of using the plugin ??

    I really like the plugin though! Simple and it works.

    Thread Starter foxymonkey

    (@foxymonkey)

    I guess I could use a regex to grab all URLs matching a specific pattern and attach the onclick afterwards as another solution?

    Plugin Author Brecht

    (@brechtvds)

    Can you give me a specific example of the code you’re using for those links (so not through our plugin, but the desired result).

    Brecht

    Thread Starter foxymonkey

    (@foxymonkey)

    Sure. Here is a snippet of the HTML I’d like to have:

    This post includes everything you need to know about 
    <a class="fbtom" href="https://www.foxymonkey.com/recommends/oddsmonkey-vs-pa/" target="_blank" rel="nofollow noopener noreferrer">OddsMonkey</a> and <a class="fbtpa" href="https://www.foxymonkey.com/recommends/profitaccummulator/" target="_blank" rel="nofollow noopener noreferrer">Profit Accumulator</a>

    With jQuery I have added this to attach the onclicks:

    var fbtoms = document.querySelectorAll('.fbtom');
    for (var i=0; i<fbtoms.length; i++) {
    	fbtoms[i].onclick = function(){fbq('track', 'Purchase', {value: 0.15,currency: 'GBP'})};
    }

    Same onclick events are attached for the second class (fbtpa).

    Plugin Author Brecht

    (@brechtvds)

    Ok, thanks for the example. I’ll look into the possibilities!

    Brecht

    Thread Starter foxymonkey

    (@foxymonkey)

    Thanks, Brecht.

    I think the easiest thing to do is to add an optional “custom class” text field when trying to create a link.

    Cheers,
    Michael

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Javascript calls onclick?’ is closed to new replies.