This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
8587119
commit 8345b3c
Showing
4 changed files
with
55 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
const NativeXTrackEndOfContent = () => import(/* webpackChunkName: "native-x-track-end-of-content" */ './track-end-of-content.vue'); | ||
const NativeXTrackSocialShare = () => import(/* webpackChunkName: "native-x-track-social-share" */ './track-social-share.vue'); | ||
const NativeXTrackOutboundLinks = () => import(/* webpackChunkName: "native-x-track-outbound-links" */ './track-outbound-links.vue'); | ||
|
||
export default (Browser) => { | ||
const { EventBus } = Browser; | ||
Browser.register('NativeXTrackEndOfContent', NativeXTrackEndOfContent); | ||
Browser.register('NativeXTrackSocialShare', NativeXTrackSocialShare, { provide: { EventBus } }); | ||
Browser.register('NativeXTrackOutboundLinks', NativeXTrackOutboundLinks); | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/marko-web-native-x/browser/track-outbound-links.vue
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,26 @@ | ||
<template> | ||
<div /> | ||
</template> | ||
|
||
<script> | ||
import { outboundLink } from '../utils/gtm-events'; | ||
export default { | ||
props: { | ||
container: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
created() { | ||
const elements = document.querySelectorAll(`${this.container} a[href]`); | ||
elements.forEach((element) => { | ||
const url = element.getAttribute('href'); | ||
element.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
outboundLink(window, url); | ||
}); | ||
}); | ||
}, | ||
}; | ||
</script> |
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
21 changes: 21 additions & 0 deletions
21
packages/marko-web-native-x/components/story/track-outbound-links.marko
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,21 @@ | ||
import defaultValue from "@parameter1/base-cms-marko-core/utils/default-value"; | ||
import { get, getAsObject } from "@parameter1/base-cms-object-path"; | ||
|
||
$ const { req } = out.global; | ||
$ const story = getAsObject(input, "story"); | ||
$ const push = defaultValue(input.push, false); | ||
|
||
<if(push)> | ||
<marko-web-gtm-push name="dataLayerNativeX" data={ | ||
story_id: story.id, | ||
page_path: req.path, | ||
page_title: story.title, | ||
publisher_id: get(story, "publisher.id"), | ||
advertiser_id: get(story, "advertiser.id"), | ||
preview_mode: Boolean(req.query.preview), | ||
} /> | ||
</if> | ||
|
||
<marko-web-browser-component name="NativeXTrackOutboundLinks" props={ | ||
container: input.container, | ||
} /> |