Search code examples
javascripttwitteraddthisadd-this-event

Js: customize #tag value generated by field name 'via' in addthis twitter share JS Plugin


i need to share a hashtag (example: #myPlutonicHash) from my website to twitter account. i have used addThis javascript object present in addThis plugin Feature, as shown below

var addthis_share = {};
addthis_share = {
title : 'PlutonicTitle',
passthrough : {
    twitter: {
        via: "#myPlutonicHash"
    }
}
};


From my website, When i click twitter icon to share the title of my website and required #tag, i get the following output which is the default text output format when used field 'via' in twitter textbox.

Output1
PlutonicTitle via @#myPlutonicHash

But, i dont need the text 'via' and '@' in my twitter text box. i need to customize the default text output format of field 'via'
. My required text output is shown below.

Output2
PlutonicTitle #myPlutonicHash

kindly help me out in getting my required output.


Solution

  • You're almost there. Here's how to do it:

    var addthis_share = {};
    addthis_share = {
    title : 'PlutonicTitle',
    passthrough : {
        twitter: {
            hashtags: "myPlutonicHash"
        }
    }
    };
    

    If you want more than one hash tag, separate them with commas like this:

    var addthis_share = {};
    addthis_share = {
    title : 'PlutonicTitle',
    passthrough : {
        twitter: {
            hashtags: "myPlutonicHash,myOtherPlutonicHash"
        }
    }
    };
    

    If you've got more questions send us an email at help@addthis.com