From 09ef9857d92f63b0f260e377b2c4a5b5d626887f Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 13 Dec 2023 15:04:28 +1100 Subject: [PATCH] feat: Dynamically inject analytics into head of sites --- sites/website.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sites/website.py b/sites/website.py index 781e272..b14bc0f 100644 --- a/sites/website.py +++ b/sites/website.py @@ -140,8 +140,29 @@ def get_template(template,hide_addresses=False): addresses = soup.find(id="addresses") addresses.decompose() except: - pass + pass + # If comment doesn't exist, add tracking to end of head + if 'Matomo' not in str(soup): + head = soup.find("head") + head.append(BeautifulSoup(""" + + + + """, 'html.parser')) + return str(soup) def calculate_contrast_ratio(color1, color2):