WebSite X5Help Center

 
John W.
John W.
User

Proper script code for AddThis social share buttons  en

Auteur : John W.
Visité 941, Followers 1, Partagé 0  

When you use the AddThis object for social sharing icons, you have to sign up with AddThis to have an account with them. Thus when in X5, you then enter your account name and the program creates this html code:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=Eclectic-ware"></script>
<!-- AddThis Button END -->

Please notice the script line, my account name is Eclectic-ware and it works.

But, AddThis has instructions that I was to add this code onto every page toward the end of the <body> html:

<!-- Go to www.addthis.com/dashboard to customize your tools --> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5dfe5586b1e4f67e"></script>

So I just took a look, both scripts are in my HTML. Not real far apart, but shown as separate scripts. I am wondering, when in X5, instead of typing Eclectic-ware in as my account name, should I use: ra-5dfe5586b1e4f67e

OR, should I just not add the html line that they told me to add and just leave the code that X5 writes in there.

I am just wondering if I am creating a conflict. Obviously, the two accounts are the same. But having an added script, and wonderful Lighthouse telling me that I have unused Javascript in my html, am I slowing down the works?

I am using AddThis so customers can share the pages. That is my only intent with it, tell others about my website. So I use the share function of it only.

Posté le
3 RéPONSES
Aleksej H.
Aleksej H.
Moderator

Hello. I added your code to my page. And it's okay. No conflicts and no changes to the added code.

Lire plus
Posté le de Aleksej H.
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator
Meilleur utilisateur du mois PT

... error! (STAMP2 172-182)... ...... HTML not in the HEAD section, but in the end section of the body ...

... for all pages:
>> Step 1 - Settings > The Advanced section > Statistics and Code > Options in the Code section | ▪Custom Code: > (6°) - Before closing the BODY tag.

... for a single page:
>> Step 3 - Map > The Page Properties window > Expert | Custom Code: >(6°) - Before closing the BODY tag.

.

ciao

.

Lire plus
Posté le de  ‪ KolAsim ‪ ‪
John W.
John W.
User
Auteur

Thank you both. AddThis answered me too and told me that the two scripts could conflict with each other. They suggested I remove the added script and I have done so.

The AddThis widget that I let X5 configure is in my footer, thus on all pages. And it repeats itself on blog pages. So at the end of the blog and shortly after in the footer below. I will deal with the double script on the blog pages, only so much control there.

Strange, when I do the test in Lighthouse, even with the page refreshed and the second line of script gone, Lighthouse still tells me that I have unused JS and that AddThis is one of them. Of course it tells me that the X5 cart is unused and many others too. Duh. I guess it just means I haven't used them in this session. Doesn't mean I should get rid of them, Google. These tools can be quite maddening.

Lire plus
Posté le de John W.