The depletion of the ozone layer has increased exposure to harmful UV rays. This has made us all more susceptible to sunburn, age spots, and even skin cancer. Finding a sunscreen that you will use ...
A tattoo is art that goes on your body and like any piece of art, it must be protected from certain elements. Unfortunately, one of the biggest culprits of ruining tattoo ink is the sun. The sun em...
You have heard it many times--from us, from dermatologists and other doctors--you need to wear SPF 30 every day. While sunscreen is extra important in the summer and on the beach, it truly should b...
Did you know that in the US, sunscreen is considered an over-the-counter (OTC) drug product? It is--just like Tylenol, cold medicines, toothpaste and more! Every over-the-counter drug has rules set...
The second topic in our Stay Healthy theme is ways to stay healthy mentally. Work and school can always cause stress and the added factor of uncertainty about COVID and finding new ways to work and...
Do you love Brush On Block’s Protective Lip Oil SPF 32? You aren’t alone! Here are some things our customers have said about it over the past year since it launched:
-Everything I hoped it to be an...
If you have young children you are probably concerned about keeping their skin protected from the sun. After all, studies have shown that sunburns in childhood dramatically increase the odds of dev...
Gabrielle “Coco” Chanel was photographed in the French Riviera sporting a suntan in 1923, and instantly, bronzed skin became a widely desired look. Not only does bronzed skin make you look sun-kiss...
You wake up in the morning, grab your phone and check the weather. It is a sunny day in winter, and as you scroll down for details, you see something called "UV Index," which--lucky you--is 0 today...
const version = "3.5";
const makeTableMap = require('makeTableMap');
const createArgumentsQueue = require('createArgumentsQueue');
const injectScript = require('injectScript');
const log = require('logToConsole');
const copyFromWindow = require('copyFromWindow');
const makeString = require('makeString');
const makeInteger = require('makeInteger');
const getUrl = require('getUrl');
const eventSourceUrl = getUrl();
if (eventSourceUrl.indexOf('gtm-msr.appspot.com') !== -1) {
log("Ignoring events sent by gtm msr: " + eventSourceUrl);
return data.gtmOnSuccess();
}
// Helper methods
const mergeObj = (obj, obj2) => {
for (let key in obj2) {
if (obj2.hasOwnProperty(key)) {
obj[key] = obj2[key];
}
}
return obj;
};
const fail = msg => {
log(msg);
data.gtmOnFailure();
};
// Field processing
const tagIds = data.tagIds.map(item => item.TagIds).filter( item => item );
if (tagIds.length === 0) {
return fail("No Amazon Ad Tag IDs configured");
}
let eventName = data.standardEventName;
if (data.eventName === "custom") {
eventName = data.customEventName;
}
if (!eventName) {
return fail("Event Name is not defined");
}
const region = data.tagRegion;
let attributes = {};
if (eventName === "Off-AmazonPurchases") {
attributes = data.offAmazonPurchaseAttributes ? makeTableMap(data.offAmazonPurchaseAttributes, 'Attribute', 'value') : {};
} else {
attributes = data.defaultAttributes ? makeTableMap(data.defaultAttributes, 'Attribute', 'value') : {};
}
const customAttributes = data.customAttributes ? makeTableMap(data.customAttributes, 'Attribute', 'value') : {};
const finalAttributes = mergeObj(attributes, customAttributes);
finalAttributes.gtmVersion = version;
for (const key in finalAttributes) {
if (!key) {
return fail("Attribute is not defined - " + key);
}
}
const gdprAatTokenAttributes = {};
const gdprEventAttributes = {};
let ttl = null;
if (data.includeTcf) {
const possibleGDPRvalues = [0, 1, 2];
if (possibleGDPRvalues.indexOf(data.gdpr) >= 0) {
gdprAatTokenAttributes.gdpr = data.gdpr;
gdprEventAttributes.gdpr = data.gdpr;
}
const possibleGDPRPDvalues = [-1, 0, 1];
if (possibleGDPRPDvalues.indexOf(data.gdprPd) >= 0) {
gdprEventAttributes.gdpr_pd = data.gdprPd;
}
if (data.gdprConsent) {
gdprAatTokenAttributes.gdprConsent = data.gdprConsent;
gdprEventAttributes.gdpr_consent = data.gdprConsent;
}
}
const tokenConfig = {
email: '',
phonenumber: '',
gdpr: { enabled: false, consent: '',},
ttl: 9600,
};
if (data.advancedMatchingList) {
let ttl = null;
if (data.ttl !== undefined && makeInteger(data.ttl) >= 0) ttl = makeInteger(data.ttl);
data.advancedMatchingList.forEach((e) => {
if (!e.paramName || !e.paramValue) {
return;
}
const paramVal = makeString(e.paramValue);
if (e.paramName === "email" && paramVal.length > 0) {
// if token config email is already set, we don't want to
tokenConfig.email = paramVal;
}
if (e.paramName === "phone" && paramVal.length > 0) {
tokenConfig.phonenumber = paramVal;
}
});
if (gdprAatTokenAttributes.gdpr) {
tokenConfig.gdpr.enabled = !!gdprAatTokenAttributes.gdpr;
}
if (gdprAatTokenAttributes.gdprConsent) {
tokenConfig.gdpr.consent = gdprAatTokenAttributes.gdprConsent;
}
if (tokenConfig.gdpr.enabled && !tokenConfig.gdpr.consent) {
return fail("GDPR consent string must be set if GDPR enabled");
}
if (ttl) {
tokenConfig.ttl = ttl;
}
log("token config =", tokenConfig);
}
// Define amzn fn in window
const getAmzn = () => {
const amzn = copyFromWindow('amzn');
if (amzn && !amzn.q) return amzn;
// Until the full library is loaded we allow calling amzn by queuing all
// calls to it. This queue is then processed when the library is loaded.
const amznq = createArgumentsQueue('amzn', 'amzn.q');
const overrideAmznFn = (a, b, c, d) => amznq([a, b, c, d]);
return overrideAmznFn;
};
// track events once amznjs script is loaded
const trackEvents = () => {
const amzn = getAmzn();
if (!amzn) {
return fail("Amazon Ad Tag not defined in browser window");
}
if (data.advancedMatchingList && ((tokenConfig.email !== '') || (tokenConfig.phonenumber !== ''))) {
amzn('setUserData', tokenConfig);
}
amzn('setRegion', region);
tagIds.forEach(item => amzn("addTag", item));
amzn('addtcfv2', gdprEventAttributes);
amzn('trackEvent', eventName, finalAttributes);
};
trackEvents();
injectScript('https://c.amazon-adsystem.com/aat/amzn.js', data.gtmOnSuccess, data.gtmOnFailure, 'amznScript');