diff --git a/examples/key_from_local_storage.html b/examples/key_from_local_storage.html new file mode 100644 index 0000000..770b0a8 --- /dev/null +++ b/examples/key_from_local_storage.html @@ -0,0 +1,147 @@ + + + + + + + + +
+ + + // Assuming you have already stored a value with the key 'myKey' + var cmpFromLocalStorage = localStorage.getItem('campaignKeyLocalStorage'); + + // For logging purposes + if (cmpFromLocalStorage !== null) { + console.log('The value of campaignKeyLocalStorage is:', cmpFromLocalStorage); + } else { + console.log('There is no value stored with the key "campaignKeyLocalStorage".'); + } + + //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: ["inmedia11", "inmedia22"], defaultValue: "my_media_default_source"}; + var campaign = {keys: [], defaultValue: cmpFromLocalStorage}; + + //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, + } + }) + + 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; + + +