diff --git a/README.md b/README.md index a45dfd900..921ae688c 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ Peak includes full SEO support. It's easy to expand on since it's al built with * Auto generated hreflang tags on localized sites. * Add knowledge graph data (organization, person or custom). * Auto generated optional JSON-ld breadcrumbs. +* Add trackers: Google Analytics, Google Tag Manager, Site Verification or Fathom. [Screenshot global](https://studio1902.ams3.cdn.digitaloceanspaces.com/assets/statamic-peak/screenshots/peak-seo-01.png) | [Screenshot per entry](https://studio1902.ams3.cdn.digitaloceanspaces.com/assets/statamic-peak/screenshots/peak-seo-02.png) | [Screenshot per entry](https://studio1902.ams3.cdn.digitaloceanspaces.com/assets/statamic-peak/screenshots/peak-seo-03.png) @@ -235,6 +236,7 @@ Peak includes full SEO support. It's easy to expand on since it's al built with If you plan on using an addon for SEO and Peak's built in features, do the following: * Remove `{{ partial:snippets/seo }}` from `resources/views/layout.antlers.html`. +* Remove `{{ yield:google_tag_manager }}` from `resources/views/layout.antlers.html`. * Remove the SEO section and import from `resources/blueprints/collections/pages/page.yaml`. * Delete the SEO global `content/globals/seo.yaml`. diff --git a/content/globals/seo.yaml b/content/globals/seo.yaml index 2e05d4633..17c55e647 100644 --- a/content/globals/seo.yaml +++ b/content/globals/seo.yaml @@ -1 +1,12 @@ -title: SEO \ No newline at end of file +title: SEO +data: + json_ld_type: none + breadcrumbs: false + sitemap_collections: + - pages + use_google_site_verification: false + use_google_analytics: false + anonymize_ip: false + use_google_tag_manager: true + google_tag_manager: CRAPFACE + use_fathom: false diff --git a/resources/blueprints/globals/seo.yaml b/resources/blueprints/globals/seo.yaml index 142e00b0e..f367bd4c8 100644 --- a/resources/blueprints/globals/seo.yaml +++ b/resources/blueprints/globals/seo.yaml @@ -139,7 +139,7 @@ sections: display: Sitemap fields: - - handle: section_siteamp + handle: section_sitemap field: type: section instructions: 'Configure the sitemap.xml' @@ -154,3 +154,90 @@ sections: listable: hidden default: pages display: Collections + trackers: + display: Trackers + fields: + - + handle: section_trackers + field: + type: section + instructions: 'Configure trackers and analytics.' + listable: false + display: Trackers + - + handle: use_google_site_verification + field: + type: toggle + instructions: 'Add a google-site-verification meta tag to your head.' + listable: false + display: 'Google site verification' + - + handle: google_site_verification + field: common.title + config: + width: 66 + display: 'Verification key' + validate: + - 'required_if:use_google_site_verification,true' + if: + use_google_site_verification: 'equals true' + - + handle: use_google_analytics + field: + type: toggle + instructions: 'Add Google Analytics tracking code to your head (privacy concern).' + listable: false + display: 'Google Analytics' + - + handle: google_analytics + field: common.title + config: + width: 66 + display: 'Tracking ID' + validate: + - 'required_if:use_google_analytics,true' + if: + use_google_analytics: 'equals true' + - + handle: anonymize_ip + field: + type: toggle + width: 33 + listable: false + display: "Anonymize IP's" + if: + use_google_analytics: 'equals true' + - + handle: use_google_tag_manager + field: + type: toggle + instructions: 'Add Google Tag Manager tracking code to your head (privacy concern).' + listable: false + display: 'Google Tag Manager' + - + handle: google_tag_manager + field: common.title + config: + width: 66 + display: 'Tracking ID' + validate: + - 'required_if:use_google_tag_manager,true' + if: + use_google_tag_manager: 'equals true' + - + handle: use_fathom + field: + type: toggle + instructions: 'Add Fathom tracking code to your head.' + listable: false + display: Fathom + - + handle: fathom + field: common.title + config: + width: 66 + display: 'Site ID' + validate: + - 'required_if:use_fathom,true' + if: + use_fathom: 'equals true' diff --git a/resources/views/layout.antlers.html b/resources/views/layout.antlers.html index 623e385cf..37d6464e8 100644 --- a/resources/views/layout.antlers.html +++ b/resources/views/layout.antlers.html @@ -14,6 +14,7 @@ x-data="{ mobileNavOpen: false }" :class="{ 'no-scroll': mobileNavOpen }" > + {{ yield:google_tag_manager }} {{ partial:layout/header }} {{ template_content }} {{ partial:layout/footer }} diff --git a/resources/views/snippets/_seo.antlers.html b/resources/views/snippets/_seo.antlers.html index 39dba878d..001ae589b 100644 --- a/resources/views/snippets/_seo.antlers.html +++ b/resources/views/snippets/_seo.antlers.html @@ -66,7 +66,7 @@ "position": {{ count }}, "name": "{{ title }}", "item": "{{ permalink }}{{ url }}" - } {{ unless last}},{{ /unless}} + } {{ unless last}},{{ /u nless}} {{ /nav:breadcrumbs }} ] } @@ -91,4 +91,39 @@ {{ elseif seo:og_image }} +{{ /if }} + +{{# Trackers #}} +{{ if seo:use_google_tag_manager }} + +{{ /if }} + +{{ if seo:use_google_tag_manager }} + {{# Yield this section in all your layouts after opening the
#}} + {{ section:google_tag_manager }} + + {{ /section:google_tag_manager }} +{{ /if }} + +{{ if seo:use_google_site_verification }} + +{{ /if }} + +{{ if seo:use_google_analytics }} + + +{{ /if }} + +{{ if seo:use_fathom }} + {{ /if }} \ No newline at end of file