feat(analytics): add basic utm nomenclature for analytics
This commit is contained in:
parent
ddeb612dc3
commit
43c5cbd8a6
18 changed files with 292 additions and 18 deletions
|
|
@ -244,7 +244,7 @@
|
|||
"fieldname": "campaign",
|
||||
"fieldtype": "Link",
|
||||
"label": "Campaign",
|
||||
"options": "Marketing Campaign"
|
||||
"options": "UTM Campaign"
|
||||
}
|
||||
],
|
||||
"has_web_view": 1,
|
||||
|
|
@ -253,7 +253,7 @@
|
|||
"index_web_pages_for_search": 1,
|
||||
"is_published_field": "published",
|
||||
"links": [],
|
||||
"modified": "2024-03-23 16:03:30.890080",
|
||||
"modified": "2024-09-03 18:48:07.263679",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Email",
|
||||
"name": "Newsletter",
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ class Newsletter(WebsiteGenerator):
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from frappe.email.doctype.newsletter_attachment.newsletter_attachment import NewsletterAttachment
|
||||
from frappe.email.doctype.newsletter_email_group.newsletter_email_group import (
|
||||
NewsletterEmailGroup,
|
||||
)
|
||||
from frappe.email.doctype.newsletter_email_group.newsletter_email_group import NewsletterEmailGroup
|
||||
from frappe.types import DF
|
||||
|
||||
attachments: DF.Table[NewsletterAttachment]
|
||||
|
|
|
|||
|
|
@ -1718,8 +1718,9 @@ Object.assign(frappe.utils, {
|
|||
{
|
||||
fieldname: "source",
|
||||
label: __("Source"),
|
||||
fieldtype: "Data",
|
||||
fieldtype: "Link",
|
||||
reqd: 1,
|
||||
options: "UTM Source",
|
||||
description: "The referrer (e.g. google, newsletter)",
|
||||
default: localStorage.getItem("tracker_url:source"),
|
||||
},
|
||||
|
|
@ -1728,13 +1729,14 @@ Object.assign(frappe.utils, {
|
|||
label: __("Campaign"),
|
||||
fieldtype: "Link",
|
||||
ignore_link_validation: 1,
|
||||
options: "Marketing Campaign",
|
||||
options: "UTM Campaign",
|
||||
default: localStorage.getItem("tracker_url:campaign"),
|
||||
},
|
||||
{
|
||||
fieldname: "medium",
|
||||
label: __("Medium"),
|
||||
fieldtype: "Data",
|
||||
fieldtype: "Link",
|
||||
options: "UTM Medium",
|
||||
description: "Marketing medium (e.g. cpc, banner, email)",
|
||||
default: localStorage.getItem("tracker_url:medium"),
|
||||
},
|
||||
|
|
@ -1746,21 +1748,32 @@ Object.assign(frappe.utils, {
|
|||
default: localStorage.getItem("tracker_url:content"),
|
||||
},
|
||||
],
|
||||
function (data) {
|
||||
async function (data) {
|
||||
let url = data.url;
|
||||
localStorage.setItem("tracker_url:url", data.url);
|
||||
|
||||
url += "?utm_source=" + encodeURIComponent(data.source);
|
||||
const { message } = await frappe.db.get_value("UTM Source", data.source, "slug");
|
||||
url += "?utm_source=" + encodeURIComponent(message.slug || data.source);
|
||||
localStorage.setItem("tracker_url:source", data.source);
|
||||
if (data.campaign) {
|
||||
url += "&utm_campaign=" + encodeURIComponent(data.campaign);
|
||||
const { message } = await frappe.db.get_value(
|
||||
"UTM Campaign",
|
||||
data.campaign,
|
||||
"slug"
|
||||
);
|
||||
url += "&utm_campaign=" + encodeURIComponent(message.slug || data.campaign);
|
||||
localStorage.setItem("tracker_url:campaign", data.campaign);
|
||||
}
|
||||
if (data.medium) {
|
||||
url += "&utm_medium=" + encodeURIComponent(data.medium);
|
||||
const { message } = await frappe.db.get_value(
|
||||
"UTM Medium",
|
||||
data.medium,
|
||||
"slug"
|
||||
);
|
||||
url += "&utm_medium=" + encodeURIComponent(message.slug || data.medium);
|
||||
localStorage.setItem("tracker_url:medium", data.medium);
|
||||
}
|
||||
if (data.medium) {
|
||||
if (data.content) {
|
||||
url += "&utm_content=" + encodeURIComponent(data.content);
|
||||
localStorage.setItem("tracker_url:content", data.content);
|
||||
}
|
||||
|
|
|
|||
9
frappe/website/doctype/utm_campaign/test_utm_campaign.py
Normal file
9
frappe/website/doctype/utm_campaign/test_utm_campaign.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2024, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestUTMCampaign(FrappeTestCase):
|
||||
pass
|
||||
8
frappe/website/doctype/utm_campaign/utm_campaign.js
Normal file
8
frappe/website/doctype/utm_campaign/utm_campaign.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) 2024, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("UTM Campaign", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"slug",
|
||||
"campaign_description"
|
||||
],
|
||||
"fields": [
|
||||
|
|
@ -17,14 +18,20 @@
|
|||
"in_filter": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Campaign Description (Optional)"
|
||||
},
|
||||
{
|
||||
"fieldname": "slug",
|
||||
"fieldtype": "Data",
|
||||
"label": "Slug",
|
||||
"unique": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-23 16:03:29.592624",
|
||||
"modified": "2024-06-28 15:05:14.714600",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Marketing Campaign",
|
||||
"name": "UTM Campaign",
|
||||
"naming_rule": "Set by user",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
|
|
@ -55,6 +62,18 @@
|
|||
{
|
||||
"role": "Desk User",
|
||||
"select": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Marketing Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# Copyright (c) 2023, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class MarketingCampaign(Document):
|
||||
class UTMCampaign(Document):
|
||||
# begin: auto-generated types
|
||||
# This code is auto-generated. Do not modify anything in this block.
|
||||
|
||||
|
|
@ -15,6 +15,9 @@ class MarketingCampaign(Document):
|
|||
from frappe.types import DF
|
||||
|
||||
campaign_description: DF.SmallText | None
|
||||
slug: DF.Data | None
|
||||
# end: auto-generated types
|
||||
|
||||
pass
|
||||
def before_save(self):
|
||||
if self.slug:
|
||||
self.slug = frappe.utils.slug(self.slug)
|
||||
0
frappe/website/doctype/utm_medium/__init__.py
Normal file
0
frappe/website/doctype/utm_medium/__init__.py
Normal file
9
frappe/website/doctype/utm_medium/test_utm_medium.py
Normal file
9
frappe/website/doctype/utm_medium/test_utm_medium.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2024, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestUTMMedium(FrappeTestCase):
|
||||
pass
|
||||
8
frappe/website/doctype/utm_medium/utm_medium.js
Normal file
8
frappe/website/doctype/utm_medium/utm_medium.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) 2024, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("UTM Medium", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
72
frappe/website/doctype/utm_medium/utm_medium.json
Normal file
72
frappe/website/doctype/utm_medium/utm_medium.json
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "prompt",
|
||||
"creation": "2024-06-28 09:46:10.102141",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"slug",
|
||||
"description"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "slug",
|
||||
"fieldtype": "Data",
|
||||
"label": "Slug",
|
||||
"unique": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-28 15:04:51.679189",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "UTM Medium",
|
||||
"naming_rule": "Set by user",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Marketing Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"report": 1,
|
||||
"role": "Desk User",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
23
frappe/website/doctype/utm_medium/utm_medium.py
Normal file
23
frappe/website/doctype/utm_medium/utm_medium.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2024, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class UTMMedium(Document):
|
||||
# begin: auto-generated types
|
||||
# This code is auto-generated. Do not modify anything in this block.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from frappe.types import DF
|
||||
|
||||
description: DF.SmallText | None
|
||||
slug: DF.Data | None
|
||||
# end: auto-generated types
|
||||
|
||||
def before_save(self):
|
||||
if self.slug:
|
||||
self.slug = frappe.utils.slug(self.slug)
|
||||
0
frappe/website/doctype/utm_source/__init__.py
Normal file
0
frappe/website/doctype/utm_source/__init__.py
Normal file
9
frappe/website/doctype/utm_source/test_utm_source.py
Normal file
9
frappe/website/doctype/utm_source/test_utm_source.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2024, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestUTMSource(FrappeTestCase):
|
||||
pass
|
||||
8
frappe/website/doctype/utm_source/utm_source.js
Normal file
8
frappe/website/doctype/utm_source/utm_source.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) 2024, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("UTM Source", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
72
frappe/website/doctype/utm_source/utm_source.json
Normal file
72
frappe/website/doctype/utm_source/utm_source.json
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "prompt",
|
||||
"creation": "2024-06-28 09:42:04.478212",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"slug",
|
||||
"description"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "slug",
|
||||
"fieldtype": "Data",
|
||||
"label": "Slug",
|
||||
"unique": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-28 15:04:59.643513",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "UTM Source",
|
||||
"naming_rule": "Set by user",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Marketing Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"report": 1,
|
||||
"role": "Desk User",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
23
frappe/website/doctype/utm_source/utm_source.py
Normal file
23
frappe/website/doctype/utm_source/utm_source.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2024, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class UTMSource(Document):
|
||||
# begin: auto-generated types
|
||||
# This code is auto-generated. Do not modify anything in this block.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from frappe.types import DF
|
||||
|
||||
description: DF.SmallText | None
|
||||
slug: DF.Data | None
|
||||
# end: auto-generated types
|
||||
|
||||
def before_save(self):
|
||||
if self.slug:
|
||||
self.slug = frappe.utils.slug(self.slug)
|
||||
Loading…
Add table
Reference in a new issue