-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ioanna0
committed
Oct 13, 2020
1 parent
884457e
commit 00188c7
Showing
8 changed files
with
119 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable -- this is third party code */ | ||
// @ts-nocheck | ||
// More details here: https://my.lotame.com/t/g9hxvnw/detailed-reference-guide | ||
|
||
export const lotameScript = (callback) => { | ||
!(function() { | ||
var lotameTagInput = { | ||
data: {}, | ||
config: { | ||
clientId: 12666, | ||
onProfileReady: function(o) { | ||
callback(o); | ||
} | ||
}, | ||
}; | ||
|
||
// Lotame initialization | ||
var lotameConfig = lotameTagInput.config || {}; | ||
var namespace = (window['lotame_' + lotameConfig.clientId] = {}); | ||
namespace.config = lotameConfig; | ||
namespace.data = lotameTagInput.data || {}; | ||
namespace.cmd = namespace.cmd || []; | ||
})(); | ||
}; | ||
/* eslint-enable */ |
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,27 @@ | ||
/* eslint-disable -- this is third party code */ | ||
// @ts-nocheck | ||
// Twitter universal website tag code | ||
// How to set up conversion tracking: https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html | ||
|
||
export const twitterScript = () => { | ||
!(function (e, t, n, s, u, a) { | ||
e.twq || | ||
((s = e.twq = function () { | ||
s.exe ? s.exe(...arguments) : s.queue.push(arguments); | ||
}), | ||
(s.version = '1.1'), | ||
(s.queue = []), | ||
(u = t.createElement(n)), | ||
(u.async = !0), | ||
(u.src = '//static.ads-twitter.com/uwt.js'), | ||
(a = t.getElementsByTagName(n)[0]), | ||
a.parentNode.insertBefore(u, a)); | ||
})(window, document, 'script'); | ||
// Insert Twitter Pixel ID and Standard Event data below | ||
twq('init', 'nyl43'); // The Guardian ID | ||
twq('track', 'PageView'); | ||
|
||
twq('init', 'ny4k9'); // PHD ID | ||
twq('track', 'PageView') | ||
}; | ||
/* eslint-enable */ |
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,13 @@ | ||
import { lotame } from './lotame'; | ||
|
||
describe('lotame', () => { | ||
it('construct lotame with correct params', () => { | ||
const lotameTag = lotame({ shouldRun: true }); | ||
expect(lotameTag).toStrictEqual({ | ||
shouldRun: true, | ||
url: '//tags.crwdcntrl.net/lt/c/12666/lt.min.js', | ||
beforeLoad: lotameTag.beforeLoad, | ||
name: 'lotame', | ||
}); | ||
}); | ||
}); |
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,32 @@ | ||
import { GetThirdPartyTag } from '../types'; | ||
import { lotameScript } from './external-scripts/lotame-script'; | ||
|
||
export type LotameData = { | ||
ozoneLotameData: Array<string>; | ||
ozoneLotameProfileId: string; | ||
}; | ||
|
||
let lotameData: LotameData; | ||
|
||
const ozoneLotameCallback = (obj: { | ||
getAudiences: () => Array<string>; | ||
getProfileId: () => string; | ||
}) => { | ||
lotameData = { | ||
ozoneLotameData: obj.getAudiences(), | ||
ozoneLotameProfileId: obj.getProfileId(), | ||
}; | ||
}; | ||
|
||
const beforeLoad = () => { | ||
lotameScript(ozoneLotameCallback); | ||
}; | ||
|
||
export const getLotameData: () => LotameData = () => lotameData; | ||
|
||
export const lotame: GetThirdPartyTag = ({ shouldRun }) => ({ | ||
shouldRun, | ||
url: '//tags.crwdcntrl.net/lt/c/12666/lt.min.js', | ||
beforeLoad, | ||
name: 'lotame', | ||
}); |
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,12 @@ | ||
import { twitterScript } from './external-scripts/twitter-script'; | ||
import { twitter } from './twitter-uwt'; | ||
|
||
describe('twitter', () => { | ||
it('construct twitter pixel with correct params', () => { | ||
expect(twitter({ shouldRun: true })).toStrictEqual({ | ||
shouldRun: true, | ||
name: 'twitter', | ||
insertSnippet: twitterScript, | ||
}); | ||
}); | ||
}); |
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,8 @@ | ||
import { GetThirdPartyTag } from '../types'; | ||
import { twitterScript as insertSnippet } from './external-scripts/twitter-script'; | ||
|
||
export const twitter: GetThirdPartyTag = ({ shouldRun }) => ({ | ||
shouldRun, | ||
name: 'twitter', | ||
insertSnippet, | ||
}); |