121117 added event triggers

This commit is contained in:
2024-08-29 14:47:22 +01:00
parent afe79b079a
commit c0404d138a
7 changed files with 99 additions and 37 deletions
+2 -1
View File
@@ -46,7 +46,8 @@ RELAYPATH = "dev-pedw-hc"
//RELAYPATH = "prod-pedw-hc" //RELAYPATH = "prod-pedw-hc"
GOOGLE_TAG_MANAGER = GTM-T78CBC3 //GOOGLE_TAG_MANAGER = GTM-T78CBC3
GOOGLE_TAG_MANAGER = G-GTWW3JT03Z
SHOWLOGIN = true SHOWLOGIN = true
SHOWREPRESENTATIONS = true SHOWREPRESENTATIONS = true
SHOWFILEUPLOAD = "false" SHOWFILEUPLOAD = "false"
+12 -4
View File
@@ -7,6 +7,7 @@ import { connect } from "react-redux";
import transLookup from "../../data/lookuptranslations.json"; import transLookup from "../../data/lookuptranslations.json";
import { formatDates } from "../utils"; import { formatDates } from "../utils";
import PaginationControl from "./pagination"; import PaginationControl from "./pagination";
import { sendGAEvent } from "@next/third-parties/google";
import { import {
getSearchDocumentDetails, getSearchDocumentDetails,
@@ -66,9 +67,6 @@ const DocumentDetails = (props) => {
console.log(currentDate); console.log(currentDate);
var valid = startDate < currentDate && endDate > currentDate; var valid = startDate < currentDate && endDate > currentDate;
console.log(valid);
ShowDocLinks = valid; ShowDocLinks = valid;
}; };
@@ -307,7 +305,17 @@ const DocumentDetails = (props) => {
} }
key={key} key={key}
onClick={() => { onClick={() => {
toggleDownLoadLink(key); toggleDownLoadLink(key),
sendGAEvent(
"event",
"DownloadedFile",
{
caseReference:
props.caseReference,
filename:
detailsObj.pinswg_name,
}
);
}} }}
> >
<span className="results-visually-hidden"> <span className="results-visually-hidden">
+14 -1
View File
@@ -3,6 +3,7 @@ import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form"; import { Field, reduxForm } from "redux-form";
import { sendGAEvent } from "@next/third-parties/google";
const required = (errorMsg) => (value) => const required = (errorMsg) => (value) =>
value || typeof value === "number" ? undefined : errorMsg; value || typeof value === "number" ? undefined : errorMsg;
@@ -126,7 +127,19 @@ let CaseSearch = (props) => {
/> />
<div className="govuk-form-group"> <div className="govuk-form-group">
<button type="submit" className="govuk-button"> <button
type="submit"
className="govuk-button"
onClick={() => {
sendGAEvent(
"event",
"SearchButtonClicked",
{
searchTerm: basicSearch.value,
}
);
}}
>
{t("home:casesearch-card-button")} {t("home:casesearch-card-button")}
</button> </button>
</div> </div>
+14 -1
View File
@@ -3,6 +3,7 @@ import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Field, reduxForm } from "redux-form"; import { Field, reduxForm } from "redux-form";
import { sendGAEvent } from "@next/third-parties/google";
const required = (errorMsg) => (value) => const required = (errorMsg) => (value) =>
value || typeof value === "number" ? undefined : errorMsg; value || typeof value === "number" ? undefined : errorMsg;
@@ -132,7 +133,19 @@ let CaseSearch = (props) => {
/> />
<div className="govuk-form-group"> <div className="govuk-form-group">
<button type="submit" className="govuk-button"> <button
type="submit"
className="govuk-button"
onClick={() => {
sendGAEvent(
"event",
"MyPortalSearchButtonClicked",
{
searchTerm: basicSearch.value,
}
);
}}
>
{t("myportal:searchcases-card-button")} {t("myportal:searchcases-card-button")}
</button> </button>
</div> </div>
+32 -22
View File
@@ -34,6 +34,8 @@ import {
getWatchedCasesProxy, getWatchedCasesProxy,
} from "../../actions"; } from "../../actions";
import { sendGAEvent } from "@next/third-parties/google";
const SearchResults = (props) => { const SearchResults = (props) => {
const { const {
searchString, searchString,
@@ -261,28 +263,36 @@ const SearchResults = (props) => {
} }
className="govuk-link--no-underline" className="govuk-link--no-underline"
onClick={() => { onClick={() => {
setCurrentReference({ sendGAEvent(
"ticketnumber": "event",
item.ticketnumber, "CaseViewed",
"currentReference": {
item.title, caseReference:
"currentType": item.ticketnumber,
"searchResultsObj", }
"incidentid": ),
item.incidentid, setCurrentReference({
"appealType": "ticketnumber":
item.pinswg_appealcasetype, item.ticketnumber,
"showLoginCheck": "currentReference":
props.showLoginCheck, item.title,
"specialistProcess": "currentType":
detailsObj.pinswg_speacialistcaseprocess != "searchResultsObj",
null || "incidentid":
detailsObj.pinswg_specialistcaseprocess != item.incidentid,
null "appealType":
? detailsObj.pinswg_speacialistcaseprocess || item.pinswg_appealcasetype,
detailsObj.pinswg_specialistcaseprocess "showLoginCheck":
: "", props.showLoginCheck,
}); "specialistProcess":
detailsObj.pinswg_speacialistcaseprocess !=
null ||
detailsObj.pinswg_specialistcaseprocess !=
null
? detailsObj.pinswg_speacialistcaseprocess ||
detailsObj.pinswg_specialistcaseprocess
: "",
});
}} }}
> >
<span className="results-visually-hidden"> <span className="results-visually-hidden">
+24 -8
View File
@@ -1,21 +1,37 @@
import Script from "next/script"; import Script from "next/script";
import React, { Fragment } from "react"; import React, { Fragment } from "react";
import { GoogleTagManager } from "@next/third-parties/google";
export const Tracking = ({ googleTagManagerID, nonce }) => ( export const Tracking = ({ googleTagManagerID, nonce }) => (
<Fragment> <>
<Script
strategy="afterInteractive"
src={`https://www.googletagmanager.com/gtag/js?id=${googleTagManagerID}`}
/>
<Script <Script
id="google-analytics" id="google-analytics"
strategy="afterInteractive" strategy="afterInteractive"
nonce={nonce}
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': __html: `
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], window.dataLayer = window.dataLayer || [];
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= function gtag(){dataLayer.push(arguments);}
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); gtag('js', new Date());
})(window,document,'script','dataLayer','${googleTagManagerID}');`,
gtag('consent', 'default', {
'analytics_storage': 'denied'
});
gtag('config', '${googleTagManagerID}', {
page_path: window.location.pathname,
});
`,
}} }}
/> />
</Fragment>
{/* <GoogleAnalytics gaId={googleTagManagerID} /> */}
{/* <GoogleTagManager gtmId={googleTagManagerID} /> */}
</>
); );
export const TrackingNoScript = ({ googleTagManagerID }) => ( export const TrackingNoScript = ({ googleTagManagerID }) => (
+1
View File
@@ -20,6 +20,7 @@
"@azure/storage-blob": "^12.17.0", "@azure/storage-blob": "^12.17.0",
"@azure/storage-queue": "^12.16.0", "@azure/storage-queue": "^12.16.0",
"@next-auth/prisma-adapter": "^1.0.7", "@next-auth/prisma-adapter": "^1.0.7",
"@next/third-parties": "latest",
"@prisma/client": "^5.7.0", "@prisma/client": "^5.7.0",
"@react-pdf/renderer": "^3.1.14", "@react-pdf/renderer": "^3.1.14",
"@redux-devtools/extension": "^3.3.0", "@redux-devtools/extension": "^3.3.0",