How to dynamically set a URL for sharing in Social Share Buttons

By default, the Social Share Buttons widget is configured to share the current page where the widget is installed. However, if you intend to share a particular page, you can use the dedicated Custom URL for Share setting. By adding this URL, it will always be the page shared, regardless of where the widget is installed.

However, if you have a website with a lot of articles/products and want to share them independently instead of sharing the whole page, there's a way to dynamically pass a custom URL to the Social Share Buttons widget. In this case, your visitors can share a direct link to the specific page by clicking on the widget under a specific article/product.

All you need to do is add this attribute to your widget installation code before the closing </div> tag:


Here's what the full code looks like with the attribute:

<script src="" data-use-service-core defer></script>
<div class="elfsight-app-WIDGET-ID" data-elfsight-app-custom-url="YOUR_POST_URL"></div>

In the code above, you need to change YOUR_POST_URL to the URL of your post or article. In addition to that, you need to replace WIDGET-ID with the ID of your own widget - Where to get your widget ID.

Here's an example of the end result:

<script src="" data-use-service-core defer></script>
<div class="elfsight-app-25af**22-d295-4**c-81e1-e4225***f791" data-elfsight-app-custom-url=""></div>

Repeat these steps for each of the posts/products that you want to add the Social Share Buttons widget to.

You can add the same widget for all the posts, just make sure to change the custom URL for each post accordingly.

Well done. You can now share any article that you want!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us