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.
Merge pull request #38 from zarathustra323/p1-events-inquiry
Create inquiry submission tracker
- Loading branch information
Showing
4 changed files
with
67 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,5 +1,10 @@ | ||
const TrackContentBodyLinks = () => import(/* webpackChunkName: "p1-events-track-content-body-links" */ './track-content-body-links.vue'); | ||
const TrackInquirySubmission = () => import(/* webpackChunkName: "p1-events-track-inquiry-submission" */ './track-inquiry-submission.vue'); | ||
|
||
export default (Browser) => { | ||
const { EventBus } = Browser; | ||
Browser.register('P1EventsTrackContentBodyLinks', TrackContentBodyLinks); | ||
Browser.register('P1EventsTrackInquirySubmission', TrackInquirySubmission, { | ||
provide: { EventBus }, | ||
}); | ||
}; |
36 changes: 36 additions & 0 deletions
36
packages/marko-web-p1-events/browser/track-inquiry-submission.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,36 @@ | ||
<template> | ||
<div class="marko-web-p1-events-inquiry-listener" style="display: none;" /> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
inject: ['EventBus'], | ||
props: { | ||
entity: { | ||
type: String, | ||
required: true, | ||
}, | ||
eventName: { | ||
type: String, | ||
default: 'inquiry-form-submit', | ||
}, | ||
}, | ||
created() { | ||
const { p1events } = window; | ||
if (!p1events) return; | ||
this.EventBus.$on(this.eventName, ({ payload } = {}) => { | ||
const props = { ...payload }; | ||
delete props.token; | ||
p1events('track', { | ||
category: 'Inquiry', | ||
action: 'Submit', | ||
entity: this.entity, | ||
props, | ||
}); | ||
}); | ||
}, | ||
}; | ||
</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
12 changes: 12 additions & 0 deletions
12
packages/marko-web-p1-events/components/track-inquiry-submission.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,12 @@ | ||
import { getAsObject } from "@parameter1/base-cms-object-path"; | ||
import eventEntity from "../utils/base-content-entity"; | ||
|
||
$ const content = getAsObject(input, "content"); | ||
|
||
<marko-web-browser-component | ||
name="P1EventsTrackInquirySubmission" | ||
props={ | ||
entity: eventEntity(content.id, content.type), | ||
eventName: input.eventName, | ||
} | ||
/> |