Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amp analytics #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Configuration/Settings.Blog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Shel:
enabled: false
twitterId: ''
facebookId: ''
analytics:
tagManager:
ampContainerId: ~
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ 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:
ampContainerId: <gtm tag manager id>
```
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.

Expand Down
19 changes: 19 additions & 0 deletions Resources/Private/Fusion/Layouts/AmpPage.fusion
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
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 >
googleTrackingScript = Neos.Fusion:Join {
main = afx`
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
`
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')}
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.ampContainerId')}

@position = 'before closingHeadTag'
}
googleTrackingCustomElement = Neos.Fusion:Join {
main = afx`
<amp-analytics config={'https://www.googletagmanager.com/amp.json?id=' + Configuration.setting('Shel.Blog.analytics.tagManager.id') + '&gtm.url=SOURCE_URL'} data-credentials="include"></amp-analytics>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<amp-analytics config={'https://www.googletagmanager.com/amp.json?id=' + Configuration.setting('Shel.Blog.analytics.tagManager.id') + '&gtm.url=SOURCE_URL'} data-credentials="include"></amp-analytics>
<amp-analytics config={'https://www.googletagmanager.com/amp.json?id=' + Configuration.setting('Shel.Blog.analytics.tagManager.ampContainerId') + '&gtm.url=SOURCE_URL'} data-credentials="include"></amp-analytics>

`
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.id')}
@if.isset = ${Configuration.setting('Shel.Blog.analytics.tagManager.ampContainerId')}

@position = 'before closingBodyTag'
}


# Additional scripts are not allowed with amp
lastVisitedNodeScript >

Expand Down