department-of-veterans-affairs / notification-api

Notification API
MIT License
16 stars 9 forks source link

Implement open rates for 526EZ confirmation #221

Closed QaysarA closed 3 years ago

QaysarA commented 4 years ago

Value Statement:

As a VANotify stakeholder I want to understand the open rates for notification emails So that I can measure and evolve the performance of notifications

Acceptance Criteria

1. GIVEN an email notification WHEN the email is sent THEN the html body contains a google tracking pixel with parametrized tags

2. GIVEN an email notification has been delivered WHEN the email is opened THEN the appropriate open rate data is visible in GA dashboard

Checklist:

Assumptions:

Additional Info/Resources:

Out of Scope:

Open Questions:

URL Component   Explanation
v=1 Protocol version within Google Analytics
tid=UA-XXXXXX-X Your Google Analytics Tracking ID
cid=555 for anonymous CLIENT_ID_NUMBER - A systematic tracking ID for the customer.
t=event Tells Google Analytics this is an Event Hit Type
ec=email    The Event Category helps segment various events
ea=open The Event Action helps specify exactly what happened
el=recipient_id Event Label specifies a unique identification for this recipient
cs=newsletter   Campaign Source allows segmentation of campaign types
cm=email    Campaign Medium could segment social vs. email, etc.
cn=Campaign_Name    Campaign Name identifies the campaign to you

example : <img src="https://www.google-analytics.com/collect?v=1&tid=UA-01010-1&cid=555&aip=1&t=event&ec=email&ea=open&dp=%2Fform%2F526ez%2Femail&dt=<email subject>">
example un-scaped: <img src="https://www.google-analytics.com/collect?v=1&tid=UA-01010-1&cid=555&aip=1&t=event&ec=email&ea=open&dp=/vanotify/va.gov/va.gov/Form 526ez template&dt=<email subject>">
saman-moshafi-va commented 3 years ago

These are the GA parameters and their values: The tid value for non-productions environments is UA-50123418-16

v=1
t=event
tid=UA-50123418-16
cid=<notification id>
aip=1
ec=email
ea=open
el=<template name>
dp=/email/vanotify/<organization name>/<service name>/<template name>
dt=<email subject>
cn=<template name>
cs=<notification api provider>
cm=email
ci=<template id>

example:

v=1
t=event
tid=UA-50123418-16
cid=894de4a5-4be3-441c-8d1c-76e054a7a5ff
aip=1
ec=email
ea=open
el=Form 526ez email confirmation
dp=/email/vanotify/va.gov/va.gov/Form 526ez email confirmation
dt=Weʼve received your application
cn=Form 526ez email confirmation
cs=gov-delivery
cm=email
ci=0c1335fc-ca67-408a-b2ae-08b91ffaceba

We need to modify the code so the required values are available. The next comment will include the required changes.

saman-moshafi-va commented 3 years ago

changes to notification utils:

When v2/notifications/email end point code has access to authenticated_service which is the service we need and can be used to get serice name. It also contains organisation_id and possibly organisation. If organization is not loaded, then the organisation_id should be used to get the organization. In celery worker the service is available when HTMLEmailTemplate is created. HTMLEmailTemplate is the notification utils that uses jinja2 template to generate html and plan emails.

saman-moshafi-va commented 3 years ago

tested on Friday 13, November 2020; tested with gmail, yahoo and outlook Analytics All Web Site Data - VA.gov Testing Environments Top Events 20201113-20201113.pdf