Support » Plugin: Better Click To Tweet » Creating Dynamic (Affiliate) URL

  • Resolved kirkward


    I have just installed your plugin and am impressed by the ability to add tweets with pre-populated text in line with the conversation of the post.

    I would like to add an affiliate code to the post URL so that logged in subscribers can earn affiliate commissions for directing their Twitter followers to my posts.

    I know enough PHP to be able to retireve the visitor affiliate ID, if they are logged in, and to ignore if they are not. I would add code to the plugin (and save a copy of the modified file as a backup) that would allow me to insert the affiliate id into a variable, and then append this variable to the URL following your instructions. The affiliate id variable would probably be something like $affid.

    How can I append this to the URL that is shortened before it is shortened by Twitter? I am formatting my tweets as … [bctt tweet=”Some text here”]

    Where would I insert this variable, and how would I code it into the pre-shortened URL?

    Kirk Ward

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ben Meredith


    Hey Kirk,

    Thanks for the message. I am actually on vacation right now until the end of the week, but when I get back in my normal routine I’ll have a look at this. One of the features coming to hopefully the next version is going to be better handling of alternate URL structures, so that might fix it. But I could also play around with adding a parameter to the shortcode for affiliate slug.

    Thanks again for the kind words about the plugin! Talk soon!


    Well Ben, I hope you are having a nice one of those.

    FYI, I have found that it is much easier for me to retrieve and use a complete alternative URL. Just developed that ability with PHP last night. Entering an alternative URL with a shortcode would be a significant improvement for most users.

    Anyhoo, I am going to play with the plugin for awhile until I figure out where I can hardcode my alternate URL until you do an update.

    FYI2 – I believe the ability to enter an alternate URL would be powerful tool for affiliate marketers, as long as it was limited to using the URL of the page it is emanating from. That gets a bit tricky, as affiliate marketers can put their affiliate ID’s into all sorts of configurations. Although, usually as a suffix.

    Enjoy your vacation, and the more I look at the simplicity of using the plugin, the more I like it.

    Kirk Ward

    Plugin Author Ben Meredith


    This is an interesting use case. Thanks for messing around with it. I’ve previously written how to use the plugin in conjunction with other URL shorteners, and I am not interested at this point in building into my plugin any tighter integration with or the like.

    It’s relatively easy to make it such that the additional affiliate slug is tacked on to the end of the full URL, but including slug in a shortened URL is trickier, and likely outside of the scope I’d want to pursue at this point. (my plugin relies on third-party plugins or the WordPress core itself to actually do the shortening)

    Let me give this some more thought. I’m already working on a way to change the URL parameter so that folks can wholesale change the outputted URL. If that were possible, you could manually shorten the URL with affiliate slug, and use that shortened URL in the url=”” parameter.

    Would it make more sense for you to add your affiliate stuff to the other plugin (mentioned in the tutorial above) as opposed to trying to add it to mine? I like where you are going, but it represents a philosophical shift for me on what my plugin does. To this point, we’ve been fairly hands-off of the shortening process.

    Plugin Author Ben Meredith


    OK, so now if you hop in and update the plugin to the latest version, you can use the url parameter to set a custom URL in your tweet.

    I updated the power user guide at to show what I mean.

    For affiliate links, just shorten the URL in, and include it in the url= parameter when you are making a click to tweet box.

    Hope that helps!

    That does help.

    Many thanks!

    I’ll give you feedback as soon as possible. Meaning, I’ve gotten reactions from my users/affiliates.

    This is actually pretty exciting and powerfull!

    Update number One – The url parameter accepts variables which allows me to dynamically create urls on page. So, no matter who the user is, if they are logged in, my script can their affiliate link url into the bctt parameter.

    Cool as goose poo so far Ben.

    Plugin Author Ben Meredith


    That’s definitely the first time anything I’ve created has ever been referred to as “cool as goose poo.” —and I couldn’t be happier about that.

    The thing you might watch out for is multiple variables (once you enter a & sign, things get hairy on Twitter’s end of the arrangement.)

    Let me know how else I can help.

    Well, cool as goose poo is supposed to be a compliment. At least here in the South (yes, the S was capitalized on purpose).

    I will be using to shorten the url before it is inserted into the variable, so I am thinking the & won’t be a problem.

    FYI, on last Friday and Saturday, a guy helped me do a hack to accomplish this same thing. Being able to do it as the shortcode parameter is so much more satisfying, and I feel, stable.

    The dynamically created generated url’s were working beautifully over the weekend, so this should be good.

    I am thinking that once an affiliate finds out that their tweet automatically includes their affiliate link, it could have some sort of viral effect.

    Thanks again, this is great.

    Plugin Author Ben Meredith


    Oh, I’m here in the South as well, so I took it as a compliment.

    Can you email me the file as you have it, so that I can see how it’s dynamically creating the slug? I’m intrigued.

    Glad you are satisfied with the plugin (and thanks for tweeting about it!)

    Code has been sent.

    Note that it is in a template I use for testing. Will be migrating it to live today.

    Just realized the code you were asking for probably was the bctt code, not my template code. Will send that now.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Creating Dynamic (Affiliate) URL’ is closed to new replies.