Viewing 3 replies - 1 through 3 (of 3 total)
  • Same question here.

    And beyond… as I would like to attach custom UTM parameters to the link and then make a shortlink out of it, but that might be a second step (if possible).

    Plugin Author micropat

    (@micropat)

    Not easily done right now, but it is planned.

    If you write JavaScript, AddToAny events could help you make it happen in the meantime:
    https://www.addtoany.com/buttons/customize/wordpress/events

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to use wordpress default shortlink for sharing’ is closed to new replies.