Step #1
Copy below <script> and paste into the <head> of your page
<!-- [Mircocodes by Kookies] HTML Embed Via Component Props --><script defer src="https://cdn.jsdelivr.net/gh/kookiesagency/attribute-based-smart-link@v1.0.0/attribute-based-smart-link.min.js"></script>Step #2: HTML Structure
<!-- Basic: turns div into a link to /about-us --><div data-mc-url="about-us"> About Us</div> <!-- Add a prefix (e.g. /company/about-us) --><div data-mc-url="about-us" data-mc-url-prefix="/company"> About Our Company</div> <!-- Add a suffix (e.g. /about-us?ref=home) --><div data-mc-url="about-us" data-mc-url-suffix="?ref=home"> About Us (with ref)</div> <!-- Open absolute URL in new tab --><div data-mc-url="https://example.com" data-mc-target="_blank"> Visit Example.com</div> <!-- Combine prefix, suffix, and open in new tab --><span data-mc-url="team" data-mc-url-prefix="/company" data-mc-url-suffix="#leadership" data-mc-target="_blank"> Meet Our Leaders</span> <!-- Use on button --><button data-mc-url="contact"> Contact Us</button>Step #3: How to Use
Apply attributes to elements on the page
Main URL
Defines the primary destination for the link. This can be a relative path (e.g., about) or an absolute URL (e.g., https://example.com). This attribute is required for the Smart Data Link to function. Where: Any clickable element (div, span, button, etc.)
data-mc-url = eg: https://example.comNote: If you use an absolute URL (starts with http:// or https://), the prefix will be ignored.
URL Prefix - Optional
Adds a path segment before the main URL. This is especially useful for CMS-driven sites, where you fetch slugs (like blog post or product slugs) from the CMS and need to prepend the collection or folder name (e.g., /blog, /products). The script automatically handles slashes for you.
data-mc-url-prefix = eg: collectionNote: If the prefix doesn't start with a /, it will be added for you. Trailing slashes are removed automatically.
URL Suffix
Appends text after the main URL, such as query parameters or hash fragments. Useful for tracking, filtering, or navigating to specific sections.
data-mc-url-suffix = eg: ?source=homeNote: You can combine suffixes with prefixes and the main URL for advanced navigation.
Link Target
Determines where the link opens. Use _blank to open in a new tab/window, or _self to open in the current tab. Default: _self
data-mc-target = eg: _blankNote: If omitted, links open in the same tab.
Working examples
This example runs live on this page.



