From 241f5d1fc23b18997cdd90a591f376f64df7da6d Mon Sep 17 00:00:00 2001 From: Maxime St-Pierre Date: Thu, 1 Mar 2018 10:32:59 -0500 Subject: [PATCH] better facebook analytics --- view/Response.class.php | 11 ++++++++++- view/template/layout/_analytics.php | 14 +++----------- view/template/mail/_subscribeForm.php | 7 ++++++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/view/Response.class.php b/view/Response.class.php index e043d1fe..6087a28e 100644 --- a/view/Response.class.php +++ b/view/Response.class.php @@ -32,7 +32,8 @@ class Response $contentSent = false, $isHeadersOnly = false, $gzipResponseContent = true, - $metaImages = []; + $metaImages = [], + $facebookAnalyticsType = "PageView"; public static function setMetaDescription($description) { @@ -352,6 +353,14 @@ class Response return $statusTexts[$code] ?? null; } + public static function setFacebookPixelAnalyticsType($type){ + static::$facebookAnalyticsType = $type; + } + + public static function getFacebookPixelAnalyticsType(){ + return static::$facebookAnalyticsType; + } + protected static function normalizeHeaderName($name): string { return preg_replace_callback( diff --git a/view/template/layout/_analytics.php b/view/template/layout/_analytics.php index 45234b75..14d2e189 100644 --- a/view/template/layout/_analytics.php +++ b/view/template/layout/_analytics.php @@ -16,18 +16,10 @@ h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; ga('require', 'GTM-NT8579P'); ga('send', 'pageview'); - + !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window,document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); - !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? - n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; - n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; - t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, - document,'script','//connect.facebook.net/en_US/fbevents.js'); - - fbq('init', '1618717031725766'); - fbq('track', 'PageView'); - - + fbq('init', '1618717031725766'); + fbq('track', ''); diff --git a/view/template/mail/_subscribeForm.php b/view/template/mail/_subscribeForm.php index dedbd15b..9a9068e5 100644 --- a/view/template/mail/_subscribeForm.php +++ b/view/template/mail/_subscribeForm.php @@ -1,7 +1,7 @@ -
+
@@ -19,5 +19,10 @@
{{email.disclaimer}}
+ + $("#mail_form").submit(function() { + fbq('track', 'Lead'); + }); +
\ No newline at end of file