Skip to content

Commit

Permalink
Merge branch 'main' into TP1-981-add-text-links-to-ideas-section-cards
Browse files Browse the repository at this point in the history
  • Loading branch information
ramram-mf authored Sep 10, 2024
2 parents 0524ac2 + 7b967f6 commit 78b6d4e
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 69 deletions.
2 changes: 1 addition & 1 deletion network-api/networkapi/donate/pagemodels/help_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DonateHelpPage(BaseDonationPage):
SynchronizedField("search_image"),
# Content tab fields
TranslatableField("title"),
TranslatableField("notice"),
SynchronizedField("notice"),
TranslatableField("body"),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

{% block ga_identifier %}
<meta name="google-site-verification" content="xuTYNuCtTC9SLIkAUtmUY9Wce5RDJofc4z4fMprPYUk" />
<meta name="ga-identifier" content="UA-87658599-15">
<!-- The current GTM ID replaced an unkown GTM container with no clear access -->
<meta name="gtm-identifier" content="GTM-PQQ8H6PM">
<script nonce="{{ request.csp_nonce }}">window.dataLayer = window.dataLayer || [];</script>
<script nonce="{{ request.csp_nonce }}">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
Expand Down
2 changes: 1 addition & 1 deletion network-api/networkapi/templates/pages/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

{% block ga_identifier %}
<meta name="google-site-verification" content="D7k-r3fHm-XfJ9E7T1uZ5aqHJG2mx-0uUZFeBUDN2lY">
<meta name="ga-identifier" content="UA-87658599-6">
<!-- The current GTM ID replaced an unkown GTM container with no clear access -->
<meta name="gtm-identifier" content="GTM-PQQ8H6PM">
<script nonce="{{ request.csp_nonce }}">window.dataLayer = window.dataLayer || [];</script>
<script nonce="{{ request.csp_nonce }}">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
Expand Down
28 changes: 28 additions & 0 deletions network-api/networkapi/wagtailpages/pagemodels/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Meta:


class CTA(CTABase):
panels = CTABase.panels

class Meta:
ordering = ["-id"]
verbose_name_plural = "CTA"
Expand Down Expand Up @@ -136,6 +138,16 @@ class Callpower(TranslatableMixin, CTA):
index.FilterField("locale_id"),
]

panels = CTA.panels + [
FieldPanel("campaign_id"),
FieldPanel("call_button_label"),
FieldPanel("success_heading"),
FieldPanel("success_text"),
FieldPanel("share_twitter"),
FieldPanel("share_facebook"),
FieldPanel("share_email"),
]

class Meta(TranslatableMixin.Meta):
ordering = ["name"]
verbose_name = "Callpower"
Expand Down Expand Up @@ -166,6 +178,11 @@ class Signup(TranslatableMixin, CTA):
index.FilterField("ask_name"),
]

panels = CTA.panels + [
FieldPanel("campaign_id"),
FieldPanel("ask_name"),
]

class Meta(TranslatableMixin.Meta):
ordering = ["name"]
verbose_name = "Signup"
Expand Down Expand Up @@ -312,6 +329,17 @@ class Petition(TranslatableMixin, CTA):
index.FilterField("show_comment_field"),
]

panels = CTA.panels + [
FieldPanel("campaign_id"),
FieldPanel("show_country_field"),
FieldPanel("show_postal_code_field"),
FieldPanel("show_comment_field"),
FieldPanel("share_twitter"),
FieldPanel("share_facebook"),
FieldPanel("share_email"),
FieldPanel("thank_you"),
]

class Meta(TranslatableMixin.Meta):
ordering = ["-id"]
verbose_name = "Petition"
Expand Down
29 changes: 24 additions & 5 deletions source/js/buyers-guide/analytics-events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactGA, GoogleAnalytics } from "../common";
import { GoogleAnalytics } from "../common";

/**
* Based on given page title and product name, generate an object to use for GA events
Expand All @@ -10,13 +10,15 @@ function getQuerySelectorEvents(pageTitle, productName) {
return {
// "site-wide" events
"[data-donate-header-button]": {
event: `donate_header_button`,
category: `buyersguide`,
action: `donate tap`,
label: `${pageTitle} donate header`,
},

// product events
"#product-company-url": {
event: `product_company_link_tap`,
category: `product`,
action: `company link tap`,
label: `company link for ${productName}`,
Expand All @@ -25,6 +27,7 @@ function getQuerySelectorEvents(pageTitle, productName) {
conditionalQuery: `#view-product-page`,
},
"#product-live-chat": {
event: `customer_support_link_tap`,
category: `product`,
action: `customer support link tap`,
label: `support link for ${productName}`,
Expand All @@ -34,6 +37,7 @@ function getQuerySelectorEvents(pageTitle, productName) {
optional_element: true,
},
"#product-email": {
event: `email_link_tap`,
category: `product`,
action: `email link tap`,
label: `email link for ${productName}`,
Expand All @@ -43,6 +47,7 @@ function getQuerySelectorEvents(pageTitle, productName) {
optional_element: true,
},
"#product-twitter": {
event: `twitter_link_tap`,
category: `product`,
action: `twitter link tap`,
label: `twitter link for ${productName}`,
Expand All @@ -52,13 +57,15 @@ function getQuerySelectorEvents(pageTitle, productName) {
optional_element: true,
},
"#creep-vote-btn": {
event: `opinion_submitted`,
category: `product`,
action: `opinion submitted`,
label: `opinion on ${productName}`,
// Custom properties (not sent to GA)
conditionalQuery: `#view-product-page`,
},
"a.privacy-policy-link": {
event: `privacy_policy_link_tap`,
category: `product`,
action: `privacy policy link tap`,
label: `policy link for ${productName}`,
Expand All @@ -67,6 +74,7 @@ function getQuerySelectorEvents(pageTitle, productName) {
conditionalQuery: `#view-product-page`,
},
".product-update-link": {
event: `update_article_link_tap`,
category: `product`,
action: `update article link tap`,
label: `update article link for ${productName}`,
Expand All @@ -77,13 +85,15 @@ function getQuerySelectorEvents(pageTitle, productName) {
optional_element: true,
},
"#mss-link": {
event: `minimum_security_standards_link_tap`,
category: `product`,
action: `minimum security standards link tap`,
label: `mss link for ${productName}`,
// Custom properties (not sent to GA)
conditionalQuery: `#view-product-page`,
},
".btn-recommend": {
event: `submit_a_product_button_tap`,
category: `buyersguide`,
action: `submit a product button tap`,
label: `submit a product button tap on ${pageTitle}`,
Expand All @@ -99,7 +109,11 @@ function getQuerySelectorEvents(pageTitle, productName) {
* @param {Object} eventData data to send as GA event
*/
function setupElementGA(element, eventData) {
element.addEventListener("click", () => ReactGA.event(eventData), true);
element.addEventListener(
"click",
() => window.dataLayer.push(eventData),
true
);
}

/**
Expand All @@ -120,7 +134,7 @@ function bindCheckboxCheckedGA(selector, eventData) {
"change",
() => {
if (checkbox.checked) {
ReactGA.event(eventData);
window.dataLayer.push(eventData);
}
},
true
Expand All @@ -147,7 +161,8 @@ function trackSearchBoxUsage() {
let searchBoxUsed = sessionStorage.getItem(SESSION_KEY);

if (!searchBoxUsed) {
ReactGA.event({
window.dataLayer.push({
event: `type_in_search_box`,
category: `buyersguide`,
action: `type in search box`,
label: `search box used`,
Expand Down Expand Up @@ -177,7 +192,8 @@ function trackGoBackToAllProductsLink() {
link.addEventListener(
"click",
() => {
ReactGA.event({
window.dataLayer.push({
event: `product_not_found_all_link_tap`,
category: `buyersguide`,
action: `product not found All link tap`,
label: `All link tap for ${searchBox.value}`,
Expand Down Expand Up @@ -228,6 +244,7 @@ const ProductGA = {

if (elements.length > 0) {
const eventData = {
event: baseData.event,
category: baseData.category,
action: baseData.action,
label: baseData.label,
Expand All @@ -248,6 +265,7 @@ const ProductGA = {
// tracks when MSS accordion on product page is expanded
if (document.querySelector(`#view-product-page`)) {
bindCheckboxCheckedGA("#view-product-page #mss-accordion-toggle", {
event: `security_expand_accordion_tap`,
category: `product`,
action: `security expand accordion tap`,
label: `detail view for MSS on for ${productName}`,
Expand All @@ -256,6 +274,7 @@ const ProductGA = {

if (document.querySelector(`body.catalog`)) {
bindCheckboxCheckedGA("body.catalog #product-filter-pni-toggle", {
event: `ding_checkbox_checked`,
category: `buyersguide`,
action: `ding checkbox checked`,
label: `ding checkbox checked on ${pageTitle}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { ReactGA } from "../../../common";
import copyToClipboard from "../../../../js/copy-to-clipboard.js";

/**
Expand All @@ -15,6 +14,7 @@ const SocialShareLink = (props) => {
props.productName
} is ${props.creepType.toUpperCase()}. What do you think? Check out the Creep-O-Meter over on @mozilla’s ${link} buyer’s guide.`;
let shareEvent = {
event: `share_vote_`,
category: `product`,
action: `share tap`,
label: `share vote `,
Expand All @@ -25,13 +25,15 @@ const SocialShareLink = (props) => {
classes += `facebook-share`;
srLabel = `Facebook`;
shareEvent.label += `to facebook`;
shareEvent.event += `to_facebook`;
link = `https://www.facebook.com/sharer/sharer.php?u=https://${link}`;
}

if (props.type === `twitter`) {
classes += `twitter-share`;
srLabel = `Twitter`;
shareEvent.label += `to twitter`;
shareEvent.event += `to_twitter`;
link = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
shareText
)}`;
Expand All @@ -41,18 +43,20 @@ const SocialShareLink = (props) => {
classes += `email-share`;
srLabel = `Email`;
shareEvent.label += `via email`;
shareEvent.event += `via_email`;
link = `mailto:?&body=${encodeURIComponent(shareText)}`;
}

if (props.type === `link`) {
classes += `link-share`;
srLabel = `Copy`;
shareEvent.label += `using a link`;
shareEvent.event += `using_a_link`;
link = `#`;
}

let trackShareAction = () => {
ReactGA.event(shareEvent);
window.dataLayer.push(shareEvent);
};

// We actually need slightly different behaviour
Expand Down
11 changes: 6 additions & 5 deletions source/js/common/template-js-handles/footer-donate-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { ReactGA } from "../react-ga-proxy.js";
* ("Donate" button on footer)
*/
export default () => {
let donateFooterBtn = document.getElementById(`donate-footer-btn`);
let donateFooterBtn = document.getElementById("donate-footer-btn");

if (donateFooterBtn) {
donateFooterBtn.addEventListener(`click`, () => {
ReactGA.event({
category: `donate`,
action: `donate button tap`,
donateFooterBtn.addEventListener("click", () => {
window.dataLayer.push({
event: "donate_button_click",
category: "donate",
action: "donate button tap",
label: `${document.title} footer`,
});
});
Expand Down
5 changes: 3 additions & 2 deletions source/js/common/template-js-handles/header-donate-button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactGA } from "../../common";
import { ReactGA } from "../react-ga-proxy.js";

/**
* Bind click handler to data-donate-header-button
Expand All @@ -11,7 +11,8 @@ export default () => {
if (donateHeaderBtn.length > 0) {
donateHeaderBtn.forEach((element) => {
element.addEventListener(`click`, () => {
ReactGA.event({
window.dataLayer.push({
event: `donate_button_tap_header`,
category: `donate`,
action: `donate button tap`,
label: `${document.title} header`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import ButtonQuit from "../atoms/button-quit.jsx";
import APIErrorMessage from "../atoms/api-error-message.jsx";
import withSubmissionLogic from "./with-submission-logic.jsx";
import utility from "../../../utility.js";
import { ReactGA } from "../../../common";
import { getText, getCurrentLanguage } from "../../petition/locales";
import { COUNTRY_OPTIONS } from "../data/country-options.js";
import { LANGUAGE_OPTIONS } from "../data/language-options.js";
Expand Down Expand Up @@ -92,7 +91,8 @@ class DefaultSignupForm extends Component {
}

handleInputFocus() {
ReactGA.event({
window.dataLayer.push({
event: `signup_form_input_focused`,
category: `signup`,
action: `form focus`,
label: `Signup form input focused`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import { ReactGA } from "../../../common";
import { getText } from "../../petition/locales";

/**
Expand Down Expand Up @@ -104,21 +103,17 @@ function withSubmissionLogic(WrappedComponent) {
* @returns {void}
*/
trackFormSubmit(formData) {
ReactGA.event({
category: `signup`,
action: `form submit tap`,
label: `Signup submitted from ${
this.props.formPosition ? this.props.formPosition : document.title
}`,
});

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "form_submission",
event: "form_submission_newsletter_signup",
category: `signup_submitted_from`,
action: `form submit tap`,
form_type: "newsletter_signup",
form_location: this.props.formPosition || null,
country: formData.country,
language: formData.language,
label: `Signup submitted from ${
this.props.formPosition ? this.props.formPosition : document.title
}`,
});
}

Expand Down
1 change: 0 additions & 1 deletion source/js/components/petition/petition-thank-you.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component } from "react";
import { ReactGA } from "../../common";
import DonationModal from "./donation-modal.jsx";
import copyToClipboard from "../../copy-to-clipboard";

Expand Down
Loading

0 comments on commit 78b6d4e

Please sign in to comment.