I want to add some URL parameters to the URL that AddThis will use, and I would only know these parameters when the user clicks share. (I have images that appear on the slider, and if the user clicks on sharing, I want to add the image number to the URL so that the URL moves you to the actual image that the user provided).
I tried using the AddThis Event API, and I get a notification when there is an event that the user is about to share. I am trying to change the url at this point, but it is not updating the url. (It seems that if I talk again, he changes it to the one I asked earlier, but again that would be obsolete).
What is the best approach to achieve this? If not through AddThis, then something better that allows it and supports common social networking platforms (Facebook, Twitter, Pinterest, Email, etc.) will also be in order.
** UPDATE **
Just to clarify what I have tried so far:
function updateAddThisUrl() { //slide_no is the variable I am adding as a URL parameter var location = window.location; var theUrl = location.protocol + '//' + location.host + location.pathname + "?image=" + slide_no; addthis_share = {url : theUrl}; addthis.update('share', 'url', theUrl); addthis.url = theUrl; addthis.ready(); } function eventHandler(evt) { updateAddThisUrl(); } addthis.addEventListener('addthis.menu.share', eventHandler);
The above only updates the URL for the subsequent share, so it only takes effect when the user clicks the Share button again (at what point is he out of date again because there will be a new image and therefore a new URL parameter). I also tried using addthis.menu.open but got the same effect, so I guess it takes the url before that. I also noticed that if I select an email address from the addthis popup menu, the addthis.menu.share event will not even addthis.menu.share .
source share