Adobe Launch has a monitoring hooks API that provides more details about the rules that passed or failed. That's a great excuse for writing a Chrome extension. This will benefit you even if you have no need or experience with Adobe Launch.
3. Why a Chrome Extension?
• Intercept, block, redirect, report all web requests
• Inject Javascript code anywhere, any time of the page
• Surface all the analytics tracking on the current web
page
4. Why a Chrome Extension?
• Inject code on the page locally without speaking to a
single web developer before the page has even
finished rendering
• Surface deep internal Adobe Launch rules information
• Report the information using little-known Javascript
console tricks
6. The Four Elements
• Manifest file
• Content script
• Popup script
• Background script
mandatory metadata
runs on the current page
runs in the extension popup
invisible broker
14. Content
• Executes on the page you see in Chrome
• Observes the page as it builds
• Intercepts the script element loading Adobe Launch
• Injects Adobe Launch monitoring hooks in response
• Receives from the extension popup the rule identifiers
• Generates the output in the console
15. Observe DOM Mutations
new MutationObserver(r => r.map(s => {
const t = s.addedNodes;
if(t && t.length==1){
const u = t[0];
if(u && u.nodeName=="SCRIPT" && /^https://assets.adobedtm.com/launch-/.test(u.src))
u.insertAdjacentElement("beforebegin", e);
};
})).observe(document.documentElement, {
childList: !0,
subtree: !0
});
16. Observe DOM Mutations
new MutationObserver(r => r.map(s => {
const t = s.addedNodes;
if(t && t.length==1){
const u = t[0];
if(u && u.nodeName=="SCRIPT" && /^https://assets.adobedtm.com/launch-/.test(u.src))
u.insertAdjacentElement("beforebegin", e);
};
})).observe(document.documentElement, {
childList: !0,
subtree: !0
});
17. Observe DOM Mutations
new MutationObserver(r => r.map(s => {
const t = s.addedNodes;
if(t && t.length==1){
const u = t[0];
if(u && u.nodeName=="SCRIPT" && /^https://assets.adobedtm.com/launch-/.test(u.src))
u.insertAdjacentElement("beforebegin", e);
};
})).observe(document.documentElement, {
childList: !0,
subtree: !0
});
31. Messaging from content
Same as for messages from popup to background
Received by popup and background
chrome.runtime.sendMessage({
somethingRandom : "Anything will do"
}, response => {
console.log(response);
});
32. Listening and responding
Only content and background scripts can listen
chrome.runtime.onMessage.addListener((message, sender,
sendResponse) => {
sendResponse({
somethingElse : "message received"
});
});
34. Console tricks
• console.group("this is an expanded group");
console.log(1);
console.log(2);
console.groupEnd();
• console.groupCollapsed("this is a collapsed group");
console.log(3);
console.log(4);
console.groupEnd();
44. References
• All the code is available at https://github.com/alban-gerome/adobe-
analytics/blob/master/README.md
• Adobe Launch monitoring hooks info at:
• https://medium.com/adobetech/launch-library-monitoring-hooks-
c674d16deae3
• https://github.com/adobe/reactor-turbine/tree/master/src/rules