Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Commit 40baa69

Browse files
authored
Merge pull request #45 from ftlabs/fix/tracking
[Fix] Client-side tracking
2 parents 0863492 + f10ac07 commit 40baa69

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

public/js/componentSecondIteration/main.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var translator;
22
var Overlay = Origami['o-overlay'];
3+
var oTracking = Origami['o-tracking'];
34
var toggleButton = document.querySelector('.ftlabs-translation__toggle');
45
var articleTitle = document.querySelector(
56
'h1.topper__headline span:first-child'
@@ -19,6 +20,8 @@ var localTranslations = {};
1920
var overlayShowCount = 0;
2021

2122
function init(langs) {
23+
initTracking();
24+
2225
var languageSelect = document.createElement('div');
2326
languageSelect.classList.add('o-forms__group');
2427
languageSelect.classList.add('ftlabs-language-options-selection');
@@ -360,12 +363,28 @@ function removeTranslation() {
360363
changeShareBar('EN', 'English');
361364
}
362365

366+
function initTracking() {
367+
var config_data = {
368+
server: 'https://spoor-api.ft.com/px.gif',
369+
context: {
370+
product: 'ftlabs'
371+
}
372+
};
373+
374+
oTracking.init(config_data);
375+
oTracking.page({
376+
content: {
377+
asset_type: 'page'
378+
}
379+
});
380+
}
381+
363382
function logComponentInteractions(interaction, language = 'EN', error = null) {
364383
document.body.dispatchEvent(
365384
new CustomEvent('oTracking.event', {
366385
detail: {
367386
action: interaction,
368-
category: 'ftlabs-translations',
387+
category: 'ftlabs-translations-test',
369388
contentID: articleId,
370389
language: language,
371390
error: error

views/content.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
4343
<script
44-
src="https://build.origami.ft.com/v2/bundles/js?modules=o-fonts@^3.3.0,o-header@^7.8.4,o-footer@^6.1.1,o-buttons@^5.16.2,o-overlay@^2.7.7,o-forms@^5.2.4,o-message@^3.1.3"></script>
44+
src="https://build.origami.ft.com/v2/bundles/js?modules=o-fonts@^3.3.0,o-header@^7.8.4,o-footer@^6.1.1,o-buttons@^5.16.2,o-overlay@^2.7.7,o-forms@^5.2.4,o-message@^3.1.3,o-tracking@^1.7.2"></script>
4545
<script src="../client/js/componentSecondIteration/splitView.js"></script>
4646
<script src="../client/js/componentSecondIteration/main.js"></script>
4747
{{> userTest/componentSecondIteration}}

0 commit comments

Comments
 (0)