2

I have an affiliate system that can generate a users affiliate id with a {affiliatecode} if they are logged in and i would like every joomla page to append the users affiliate tracker id to every page so that when they share a link or video ect it will be tracked. Does any one know how to go about this in the core joomla system? Thank you in advance

1

You could use something like the following:

jQuery(document).ready(function($) {

    var querystring = 'affiliate=12345';

    $('a').each(function() {
        var href = $(this).attr('href');

        if (href)
        {
            href += (href.match(/\?/) ? '&' : '?') + querystring;
            $(this).attr('href', href);
        }
    });

});

Source: https://stackoverflow.com/a/11526172/1362108

Of course changing affiliate=12345 to whatever your affiliate code is.

  • @brigitte18 - I've made a small fix. Please re-try if you've started already – Lodder Mar 30 '16 at 15:54
  • It works great with strings, is there a way to generate the actual {snippet} like how joomla generates userid on the end of a url i need it to generate the users tracker id. when i replace the string with the curly brace it goes blank – brigitte18 Mar 30 '16 at 16:04
  • What does {snippet} normally output? Can you give an example? – Lodder Mar 30 '16 at 16:12
  • i add {affiliate_link} and it generates ?atid=1 for affilitate tracker id 1 – brigitte18 Mar 30 '16 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.