Thanks, got this to work.
Now appending UTM parameters, then creating a bit.ly shortlink. Example:
var a2a_config = a2a_config || {};
a2a_config.callbacks.push({
share: function(share_data) {
// Parameters
var params = '?utm_source=source&utm_medium=medium';
// The shared URL
var old_url = share_data.url;
// Initialize new shared URL
var new_url = old_url;
// Add parameters if not already added to the shared URL
if ( old_url.indexOf(params, old_url.length - params.length) === -1 ) {
new_url = old_url + params;
}
// Modify the share by returning an object
// with a "url" property containing the new URL
if (new_url != old_url) {
return {
url: new_url
};
}
}
});
a2a_config.track_links = 'bitly';
a2a_config.track_links_key = 'addtoany|R_cc6a4017b0274d1d86f2397771b70136';
a2a_config.templates = {
twitter: "${title} ${link} via @twitter-username"
};
But this means my bit.ly credentials are now accessible (in the example it’s from addtoany)…
Any chance you could show how to do this via functions.php instead? Or should I open a new question/thread for this?
Thanks a lot for your support!