1const getUrlParams = () => { 2 return new URLSearchParams(window.location.search); 3}; 4 5const getUtmParams = () => { 6 const source = getUrlParams().get("utm_source") || "web"; 7 const campaign = getUrlParams().get("utm_campaign") || "na"; 8 const content = getUrlParams().get("utm_content") || "na"; 9 10 return { source, campaign, content }; 11} 12 13const createAppStoreUrl = ({ source, campaign, content }) => { 14 // app id 15 const id = "1555067486"; 16 // provider token 17 const pt = "122463298"; 18 // media type 19 const mt = "8"; 20 // campaign 21 const ct = [source, campaign, content].join('_') 22 23 return `https://apps.apple.com/de/app/plantura-dein-grüner-daumen/id${id}?pt=${pt}&ct=${ct}&mt=${mt}`; 24} 25 26const createPlayStoreUrl = ({ source, campaign, content }) => { 27 const id = "garden.plantura.app.main"; 28 29 return `https://play.google.com/store/apps/details?id=${id}&referrer=utm_source%3D${source}%26utm_campaign%3D${campaign}%26utm_content%3D${content}`; 30} 31 32const replaceLinks = (cssClass, url) => { 33 const anchors = document.querySelectorAll(`a.${cssClass}`) 34 anchors.forEach(a => a.setAttribute("href", url)) 35} 36 37const replaceAppStoreLinks = (url) => { 38 replaceLinks("ios", url); 39}; 40 41const replacePlayStoreLinks = (url) => { 42 replaceLinks("android", url); 43}; 44 45const updateStoreLinks = () => { 46 const utm = getUtmParams(); 47 48 const appStoreUrl = createAppStoreUrl(utm); 49 replaceAppStoreLinks(appStoreUrl); 50 51 const playStoreUrl = createPlayStoreUrl(utm); 52 replacePlayStoreLinks(playStoreUrl); 53}; 54 55window.onload = () => { 56 updateStoreLinks(); 57 console.log("Links updated.") 58};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.