I wish to append some URL parameters to the URL to be shared by the AddThis and I would only know these parameters at the point when the user clicks share. (I have some images being shown in a slider and if the user clicks share I want to append the image number to the URL so that the URL takes you to the actual image the user shared).
I tried to use the AddThis Event API and I get notified when there is the event that the user is going to share. I try to change the URL at that point but it doesn't update the URL. (It seems that if I share again it does change it to the one I had previously set, but again this would be outdated).
What is the best approach to achieve this? If not through AddThis anything better that allows this and supports the common social media platforms (Facebook, Twitter, Pinterest, Email, etc.) would also be OK.
** UPDATE **
Just to clarify what I have tried out 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 updates the URL only for the subsequent share, so it only takes effect when the user clicks Share again (at which point it is again outdated because there would be a new image and thus a new URL parameter). I also tried to use addthis.menu.open
but got the same effect, so I guess it is taking the URL before that. I also noticed that if I choose email from the addthis popup menu the addthis.menu.share
event doesn't even get triggered.