Tracking iframe campaign clicks.
This commit is contained in:
parent
f59429c30a
commit
7f74d227f0
|
@ -9,6 +9,8 @@
|
||||||
marginwidth="0"
|
marginwidth="0"
|
||||||
marginheight="0"
|
marginheight="0"
|
||||||
class="campaign frame"
|
class="campaign frame"
|
||||||
|
data-umami-event="campaign-click"
|
||||||
|
:data-umami-event-campaign-id="`${campaign.entity.slug}-${campaign.id}`"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -96,17 +96,29 @@ function scrollToTop() {
|
||||||
this.$refs.content.scrollTop = 0;
|
this.$refs.content.scrollTop = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trackIframeCampaign() {
|
||||||
|
// no way to capture clicks from an iframe directly
|
||||||
|
if (window.umami && document.activeElement.tagName === 'IFRAME' && document.activeElement.dataset.umamiEvent === 'campaign-click') {
|
||||||
|
window.umami.track('campaign-click', {
|
||||||
|
'campaign-id': document.activeElement.dataset.umamiEventCampaignId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function mounted() {
|
function mounted() {
|
||||||
document.addEventListener('click', this.blur);
|
document.addEventListener('click', this.blur);
|
||||||
window.addEventListener('resize', this.resize);
|
window.addEventListener('resize', this.resize);
|
||||||
|
|
||||||
this.events.on('toggleSettings', this.toggleSettings);
|
this.events.on('toggleSettings', this.toggleSettings);
|
||||||
this.events.on('toggleSidebar', this.toggleSidebar);
|
this.events.on('toggleSidebar', this.toggleSidebar);
|
||||||
|
|
||||||
|
window.addEventListener('blur', this.trackIframeCampaign);
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeUnmount() {
|
function beforeUnmount() {
|
||||||
document.removeEventListener('click', this.blur);
|
document.removeEventListener('click', this.blur);
|
||||||
window.removeEventListener('resize', this.resize);
|
window.removeEventListener('resize', this.resize);
|
||||||
|
window.removeEventListener('blur', this.trackIframeCampaign);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -129,10 +141,11 @@ export default {
|
||||||
mounted,
|
mounted,
|
||||||
beforeUnmount,
|
beforeUnmount,
|
||||||
methods: {
|
methods: {
|
||||||
|
setConsent,
|
||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
toggleFilters,
|
toggleFilters,
|
||||||
toggleSettings,
|
toggleSettings,
|
||||||
setConsent,
|
trackIframeCampaign,
|
||||||
blur,
|
blur,
|
||||||
resize,
|
resize,
|
||||||
scroll,
|
scroll,
|
||||||
|
|
Loading…
Reference in New Issue