forked from DebaucheryLibrarian/traxxx
Tracking iframe campaign clicks.
This commit is contained in:
parent
f59429c30a
commit
7f74d227f0
|
@ -9,6 +9,8 @@
|
|||
marginwidth="0"
|
||||
marginheight="0"
|
||||
class="campaign frame"
|
||||
data-umami-event="campaign-click"
|
||||
:data-umami-event-campaign-id="`${campaign.entity.slug}-${campaign.id}`"
|
||||
/>
|
||||
|
||||
<a
|
||||
|
|
|
@ -96,17 +96,29 @@ function scrollToTop() {
|
|||
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() {
|
||||
document.addEventListener('click', this.blur);
|
||||
window.addEventListener('resize', this.resize);
|
||||
|
||||
this.events.on('toggleSettings', this.toggleSettings);
|
||||
this.events.on('toggleSidebar', this.toggleSidebar);
|
||||
|
||||
window.addEventListener('blur', this.trackIframeCampaign);
|
||||
}
|
||||
|
||||
function beforeUnmount() {
|
||||
document.removeEventListener('click', this.blur);
|
||||
window.removeEventListener('resize', this.resize);
|
||||
window.removeEventListener('blur', this.trackIframeCampaign);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -129,10 +141,11 @@ export default {
|
|||
mounted,
|
||||
beforeUnmount,
|
||||
methods: {
|
||||
setConsent,
|
||||
toggleSidebar,
|
||||
toggleFilters,
|
||||
toggleSettings,
|
||||
setConsent,
|
||||
trackIframeCampaign,
|
||||
blur,
|
||||
resize,
|
||||
scroll,
|
||||
|
|
Loading…
Reference in New Issue