From 92681d31c069bbcd5031a026c3e003cacae5659e Mon Sep 17 00:00:00 2001 From: vonloh Date: Wed, 9 Sep 2020 00:40:41 +0200 Subject: [PATCH 1/6] ad amp google analytics tags disable neos google analytics injections and add own tag manager logic --- Resources/Private/Fusion/Layouts/AmpPage.fusion | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Resources/Private/Fusion/Layouts/AmpPage.fusion b/Resources/Private/Fusion/Layouts/AmpPage.fusion index 8174be1..5e7d3e2 100644 --- a/Resources/Private/Fusion/Layouts/AmpPage.fusion +++ b/Resources/Private/Fusion/Layouts/AmpPage.fusion @@ -1,4 +1,16 @@ prototype(Shel.Blog:Layout.AmpPage) < prototype(Neos.Neos:Page) { + # Disable Neos.GoogleAnalytics and include amp tag manager -> https://support.google.com/tagmanager/answer/9205783?hl=en + googleTagManagerNoScript > + googleTracking > + googleTracking = Neos.Fusion:Join { + main = afx` + + + ` + @if.isset = ${Configuration.setting('Shel.Blog.amp.analytics.tagManager.id')} + @position = 'after headTag 100' + } + # Additional scripts are not allowed with amp lastVisitedNodeScript > From 52ec4fcdce9b393b7c4048a010d259e50d5924fe Mon Sep 17 00:00:00 2001 From: vonloh Date: Wed, 9 Sep 2020 00:43:28 +0200 Subject: [PATCH 2/6] add analytic tag manager to Blog settings --- Configuration/Settings.Blog.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Configuration/Settings.Blog.yaml b/Configuration/Settings.Blog.yaml index 28341af..245a8ee 100644 --- a/Configuration/Settings.Blog.yaml +++ b/Configuration/Settings.Blog.yaml @@ -8,3 +8,6 @@ Shel: enabled: false twitterId: '' facebookId: '' + analytics: + tagManager: + id: ~ From 5ac4fcdef86cea507454f29abbec187cb4441356 Mon Sep 17 00:00:00 2001 From: vonloh Date: Wed, 9 Sep 2020 01:07:07 +0200 Subject: [PATCH 3/6] update readme add GTM descriptions to APM section --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 56b9691..199c4e2 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,17 @@ If you have additional custom content elements in a blog article like videos and you might need to provide processors to make them compatible with AMP. See the `replaceImgTags` image processor as example. +If you have installed the neos/googleanalytics package aside with shel/blog all analytics tags will be diabled to be AMP confirmative. +You could add a tag manager with + +```yaml +Shel: + Blog: + analytics: + tagManager: + id: +``` + Please test the AMP version every time you add new features to your blog pages! Also be sure to check Google Search Console on your live site as it will inform you of errors. From 69ed4408652be9375c16a583f5d97003e8a56eb1 Mon Sep 17 00:00:00 2001 From: Mrtin von Loh Date: Tue, 15 Sep 2020 22:55:03 +0200 Subject: [PATCH 4/6] rename analytics settings for tagManager container --- Configuration/Settings.Blog.yaml | 2 +- Resources/Private/Fusion/Layouts/AmpPage.fusion | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/Settings.Blog.yaml b/Configuration/Settings.Blog.yaml index 245a8ee..e18e35d 100644 --- a/Configuration/Settings.Blog.yaml +++ b/Configuration/Settings.Blog.yaml @@ -10,4 +10,4 @@ Shel: facebookId: '' analytics: tagManager: - id: ~ + ampContainerId: ~ diff --git a/Resources/Private/Fusion/Layouts/AmpPage.fusion b/Resources/Private/Fusion/Layouts/AmpPage.fusion index 5e7d3e2..ad905f8 100644 --- a/Resources/Private/Fusion/Layouts/AmpPage.fusion +++ b/Resources/Private/Fusion/Layouts/AmpPage.fusion @@ -7,7 +7,7 @@ prototype(Shel.Blog:Layout.AmpPage) < prototype(Neos.Neos:Page) { ` - @if.isset = ${Configuration.setting('Shel.Blog.amp.analytics.tagManager.id')} + @if.isset = ${Configuration.setting('Shel.Blog.amp.analytics.tagManager.ampContainerId')} @position = 'after headTag 100' } From dc7fd95caa91daedb505e9f86ac72260ab9367f3 Mon Sep 17 00:00:00 2001 From: Mrtin von Loh Date: Tue, 15 Sep 2020 23:02:16 +0200 Subject: [PATCH 5/6] update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 199c4e2..f63d1cd 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,9 @@ Shel: Blog: analytics: tagManager: - id: + ampContainerId: ``` +Please refer to [this page](https://support.google.com/tagmanager/answer/9205783?hl=en) for a detailed instruction how to set up a tagmanager container for amp Please test the AMP version every time you add new features to your blog pages! Also be sure to check Google Search Console on your live site as it will inform you of errors. From 5525f4536a0baed54c79a928c2ba5dcef3b72fa0 Mon Sep 17 00:00:00 2001 From: Mrtin von Loh Date: Thu, 17 Sep 2020 00:11:48 +0200 Subject: [PATCH 6/6] update scripts to be places amp confrom --- Resources/Private/Fusion/Layouts/AmpPage.fusion | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Resources/Private/Fusion/Layouts/AmpPage.fusion b/Resources/Private/Fusion/Layouts/AmpPage.fusion index ad905f8..cfeaf92 100644 --- a/Resources/Private/Fusion/Layouts/AmpPage.fusion +++ b/Resources/Private/Fusion/Layouts/AmpPage.fusion @@ -2,15 +2,22 @@ prototype(Shel.Blog:Layout.AmpPage) < prototype(Neos.Neos:Page) { # Disable Neos.GoogleAnalytics and include amp tag manager -> https://support.google.com/tagmanager/answer/9205783?hl=en googleTagManagerNoScript > googleTracking > - googleTracking = Neos.Fusion:Join { + googleTrackingScript = Neos.Fusion:Join { main = afx` + ` + @if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')} + @position = 'before closingHeadTag' + } + googleTrackingCustomElement = Neos.Fusion:Join { + main = afx` ` - @if.isset = ${Configuration.setting('Shel.Blog.amp.analytics.tagManager.ampContainerId')} - @position = 'after headTag 100' + @if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')} + @position = 'before closingBodyTag' } + # Additional scripts are not allowed with amp lastVisitedNodeScript >