Expand my Community achievements bar.

Data from Email template to landing page

Avatar

Level 1

I have a use case where I need to pass a dynamic ID (such as a reward ID) from an email template to an AJO landing page. My goal is for the landing page to use JavaScript to fetch this ID from the URL and personalize the experience accordingly.
I understand how to retrieve URL parameters on the landing page using JavaScript. However, I’m having trouble configuring my email template’s anchor tag to include the dynamic reward ID as a parameter in the URL when a recipient clicks the link. I tried using this HTML code but it didn't work:

<script>
function insertIdIntoURL(newId) {
    const url = new URL(window.location);
    url.searchParams.set('id', newId);
    window.history.replaceState({}, '', url);
}

 
document.addEventListener('DOMContentLoaded', function () {
    const button = document.getElementById('sendIdBtn');
    if (button) {
        button.addEventListener('click', function () {
            const idToSend = 'YOUR_ID_VALUE';
            insertIdIntoURL(idToSend);
        });
    }
});
</script>
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies