// Assuming you have already stored a value with the key 'myKey' var productIdFromLocalStorage = localStorage.getItem('deepLinkValueKeyLocalStorage'); // For logging purposes if (productIdFromLocalStorage !== null) { console.log('The value of deepLinkValueKeyLocalStorage is:', productIdFromLocalStorage); } else { console.log('There is no value stored with the key "deepLinkValueKeyLocalStorage".'); } //Initializing Smart Script arguments var oneLinkURL = "https://engmntqa.onelink.me/LtRd/"; // If non of the media source keys are NOT FOUND on the link and NO default value is found, the script will return a null string var mediaSource = {keys: ["inmedia22"], defaultValue: "my_media_default_source"}; var campaign = {keys: ["incmp11"]}; var deepLinkValue = {keys: [], defaultValue: productIdFromLocalStorage}; //Function is embedded on the window object in a global parameter called window.AF_SMART_SCRIPT. //Onelink URL is generated var result = window.AF_SMART_SCRIPT.generateOneLinkURL({ oneLinkURL, afParameters:{ mediaSource: mediaSource, campaign: campaign, deepLinkValue: deepLinkValue } }) var result_url = "No output from script" if (result) { result_url = result.clickURL; document.getElementById('andrd_link').setAttribute('href', result_url); document.getElementById('ios_link').setAttribute('href', result_url); } document.getElementById('output_url').innerHTML = result_url;