generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TDW-2152 Update Ad Speed and Parameters #108
Open
Mark-M-Ensemble
wants to merge
15
commits into
main
Choose a base branch
from
TDW-2152-Ad-Fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
48f5f94
- Move Ad Logic Elsewhere
Mark-M-Ensemble c599457
- Lint Fix
Mark-M-Ensemble c246412
- Lint Fix
Mark-M-Ensemble 6687474
- Lint Fix
Mark-M-Ensemble 02f790b
- Added Ad parameters
Mark-M-Ensemble 4e9fe66
- Added Ad parameters
Mark-M-Ensemble f017687
- Added Ad parameters
Mark-M-Ensemble 6ac9fdd
- Update pageName handling
Mark-M-Ensemble 3fcc7ba
- Lint Fix
Mark-M-Ensemble 5d1af64
- Removed unused function
Mark-M-Ensemble ad607c5
- Removed unused function
Mark-M-Ensemble bd6b2e8
- test push
Mark-M-Ensemble ee7bb8f
- test push
Mark-M-Ensemble 6432809
- test push
Mark-M-Ensemble 5e00d65
- test push
Mark-M-Ensemble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// eslint-disable-next-line import/no-cycle | ||
import { | ||
decorateBlock, | ||
fetchPlaceholders, | ||
loadBlock, | ||
loadScript, | ||
sendAnalyticsPageEvent, | ||
} from './scripts.js'; | ||
|
||
const placeholders = await fetchPlaceholders(); | ||
const isProd = window.location.hostname.endsWith(placeholders.hostname); | ||
|
||
/* setup cookie preferences */ | ||
function getCookie(cookieName) { | ||
const name = `${cookieName}=`; | ||
const decodedCookie = decodeURIComponent(document.cookie); | ||
const split = decodedCookie.split(';'); | ||
// eslint-disable-next-line no-plusplus | ||
for (let i = 0; i < split.length; i++) { | ||
let c = split[i]; | ||
while (c.charAt(0) === ' ') c = c.substring(1); | ||
if (c.indexOf(name) === 0) return c.substring(name.length, c.length); | ||
} | ||
return null; | ||
} | ||
|
||
async function OptanonWrapper() { | ||
const geoInfo = window.Optanon.getGeolocationData(); | ||
Object.keys(geoInfo).forEach((key) => { | ||
const cookieName = `PGAT_${key.charAt(0).toUpperCase() + key.slice(1)}`; | ||
const cookie = getCookie(cookieName); | ||
if (!cookie || cookie !== geoInfo[key]) document.cookie = `${cookieName}=${geoInfo[key]}`; | ||
}); | ||
|
||
const prevOptIn = localStorage.getItem('OptIn_PreviousPermissions'); | ||
if (prevOptIn) { | ||
try { | ||
const settings = JSON.parse(prevOptIn); | ||
if (settings.tempImplied) { | ||
localStorage.removeItem('OptIn_PreviousPermissions'); | ||
} | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('OptIn_PreviousPermissions parse failed'); | ||
} | ||
} | ||
sendAnalyticsPageEvent(); | ||
} | ||
|
||
const otId = placeholders.onetrustId; | ||
if (otId) { | ||
const cookieScript = loadScript('https://cdn.cookielaw.org/scripttemplates/otSDKStub.js'); | ||
cookieScript.setAttribute('data-domain-script', `${otId}${isProd ? '' : '-test'}`); | ||
cookieScript.setAttribute('data-dlayer-name', 'dataLayer'); | ||
cookieScript.setAttribute('data-nscript', 'beforeInteractive'); | ||
|
||
const gtmId = placeholders.googletagmanagerId; | ||
if (gtmId) { | ||
const GTMScript = document.createElement('script'); | ||
GTMScript.innerHTML = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
})(window,document,'script','dataLayer','${gtmId}');`; | ||
document.head.append(GTMScript); | ||
|
||
const GTMFrame = document.createElement('no-script'); | ||
GTMFrame.innerHTML = `<iframe src="https://www.googletagmanager.com/ns.html?id=${gtmId}" | ||
height="0" width="0" style="display:none;visibility:hidden"></iframe>`; | ||
document.body.prepend(GTMFrame); | ||
} | ||
|
||
window.OptanonWrapper = OptanonWrapper; | ||
|
||
if (document.querySelector('.marketing')) { | ||
const marketingBlock = document.querySelector('.marketing'); | ||
decorateBlock(marketingBlock); | ||
loadBlock(marketingBlock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, we can remove this function because we are not using it in GTM to fire page load events