Skip to main content

Generic and dynamic integration on product pages

Written by Snackeet Team

⚠️ Please note that this type of integration requires a developer.

Pass on dynamic information or identify logged-in users using variables through this script. Read this article

What is Dynamic Widget Integration?

Dynamic widget integration allows for the display of different widgets on various pages through a single integration within the page template.

With this method, you can easily edit your content directly from Snackeet dashboard and assign the right widget to the right product page.

To implement this, you must integrate the code into all the product pages where you want the widget to appear. Ensure the placement aligns with your team's agreed-upon location.

Important points to consider:

  • All widgets must have the same shape and size to maintain consistency.

In the widget integration tab, copy the widget code.

then edit the script manually by replacing widgetScript.dataset.snktId="6602ca2987cee6a05f8d00e2";

by

widgetScript.dataset.snktDynamicAlias="MY_ALIAS";


<!-- Snackeet --> <script> var currentScript = document.currentScript; var widgetScript = document.createElement('script'); widgetScript.src="https://widget.snackeet.com/script.js"; widgetScript.defer = true;
widgetScript.dataset.snktProjectId="60587be7d260964fbd54692a";

widgetScript.dataset.snktDynamicAlias="MY_ALIAS";

currentScript.insertAdjacentElement('afterend', widgetScript); </script> <!-- End Snackeet -->

In the code provided, you will have to replace : MY_ALIAS

  • MY_ALIAS must be replaced by a unique identifier for the page, such as its slug or as a unique identifier.

Any identifier will do. We recommend using the slug because it's easier for the person creating the content to retrieve it afterward.

Once the code has been integrated, all you have to do is create a new widget using the page identifier as an alias for the widget in the dynamic alias field;


​

The widget will appear on your web page as soon as you save it.

Did this answer your question?