Skip to content
Gallery
nytgames
CreativeTech Wiki (internal)
Share
Explore
Bespoke FlexXL Workflow

icon picker
Coding

References and conventions on about bespoke FlexXL units.

Repository

Create a branch from main using the following format:
[Jira-Ticket-Code]-[clientname]-[optional-additional-keywords]
Create a folder in the correct year folder and start coding.

Standards to follow

Our ad units follow a set of standards and best practices. For this reason, we have a to start a bespoke project.
If you want to start from scratch, please take care of the following details.

Unit sizing

We use calculated heights FlexXLs to ensure the optimal visibility in different ad slots.
You can use this snippet as a base to size your unit.
body {
--height: calc(100vw * 1.88);
--min-height: 400px;
--max-height: 600px;
height: var(--height);
min-height: var(--min-height);
max-height: var(--max-height);
}

@media screen and (min-width: 350px) and (max-width: 414px) and (max-height: calc(100vw * 2)) {
body {
--height: calc(100vw * 1.5);
}
}

@media screen and (max-width: 374px) {
body {
--height: calc(100vw * 1.5);
}
}

GAM Macros

The code must include a series of macros to be used by the architecture serving our ads.

Unit wrapper

<body
data-pos="%%PATTERN:pos%%"
data-prop="%%PATTERN:prop%%"
data-uap="%%PATTERN:uap%%"
>
<div
data-vp="%%PATTERN:vp%%"
data-prop="%%PATTERN:prop%%"
data-pos="%%PATTERN:pos%%"
data-uap="%%PATTERN:uap%%"
>
<!-- Unit code -->
</div>
</body>

Outbound Links

<a
href="%%CLICK_URL_UNESC%%%%DEST_URL_UNESC%%"
target="_blank"
class="button"
onclick='(function(){ET.track({
type:"clickURL",
location: "item name .. (ie: logo, background ..."});})()'
>Link Label</a
>

/* sample */
<a target="_blank" href="%%CLICK_URL_UNESC%%%%DEST_URL%%" onclick='(function(){ET.track({type:"clickURL", location: "logo"});})()'> <img> logo image .... </>
</a>

Tracking

Then unit must include the Event Tracker (ET) script, after the unit code to implement effective event monitoring of our ad units. (please keep the script below inside the <body> script goes here ... </body> tags)
<script id="ad-ET-v-5.0">

const loadScript=(t,e=!0,a="text/javascript")=>new Promise((s,r)=>{try{let d=document.createElement("script");d.type=a,d.async=e,d.src=t,d.addEventListener("load",t=>{s({status:!0})}),d.addEventListener("error",t=>{r({status:!1,message:`Failed to load the script ${t}`})}),document.body.appendChild(d)}catch(c){r(c)}});

const ETwithRandom = 'https://static01.nytimes.com/ads/creative-tech/flex-frames/lib/ad-tracking.min.js';

loadScript(ETwithRandom)
.then(data => {
window.PageViewID = 'PID_placeholder';
let TAPV_ID = '%%PATTERN:ta_page_view_id%%';
let NYTPV_ID = '%%PATTERN:page_view_id%%';
PageViewID = TAPV_ID !== '' ? TAPV_ID : NYTPV_ID;
window.GAMdata = {
prop: '%%PATTERN:prop%%',
pos: '%%PATTERN:pos%%',
exit: '%%CLICK_URL_UNESC%%%%DEST_URL_UNESC%%',
ctx_id: '%%context_id%%',
lineitemid: '%eaid!',
viewport: '%%PATTERN:vp%%',
orderid: '%ebuy!',
creativeid: '%ecid!',
uap: '%%PATTERN:uap%%',
pv_id: PageViewID,
subject: 'dfp-ad-events',
numberOfSlides: 1, /* if this is a slideshow, please add the number of slides here, if it's not a slideshow, please just keep it 1 */
};
ET.init(GAMdata);
})
.catch(e => {
console.error(e);
});
</script>

Track Method

The "track" method is designed to manually track events. It accepts an object with two properties. Please refers to the to adapt your labels to the current conventions.
if (window.ET) {
ET.track({
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.