Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Create inquiry submission tracker
Browse files Browse the repository at this point in the history
Pushes the inquiry payload to P1 events
  • Loading branch information
zarathustra323 committed Mar 5, 2021
1 parent f00f2a3 commit b9135be
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/marko-web-p1-events/browser/index.js
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 packages/marko-web-p1-events/browser/track-inquiry-submission.vue
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>
14 changes: 14 additions & 0 deletions packages/marko-web-p1-events/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
"@action": "string",
"@category": "string"
},
"<marko-web-p1-events-track-inquiry-submission>": {
"template": "./track-inquiry-submission.marko",
"<content>": {
"@id": {
"type": "number",
"required": true
},
"@type": {
"type": "string",
"required": true
}
},
"@event-name": "string"
},
"<marko-web-p1-events-track-website-section>": {
"template": "./track-website-section.marko",
"@node": "object"
Expand Down
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,
}
/>

0 comments on commit b9135be

Please sign in to comment.