-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #3
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
Open
AliAghamiriBettermode
wants to merge
6
commits into
master
Choose a base branch
from
dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev #3
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dadfcb8
Refactor Google Analytics integration in head.liquid to use script ma…
693004e
Update CircleCI configuration to include 'dev' branch in workflows fo…
551a8d0
Refactor CircleCI configuration to enhance Docker image build and dep…
ffcc04a
Refactor Google Analytics integration in head.liquid to streamline sc…
9d44c4d
Enhance Google Analytics integration in head.liquid by adding conditi…
c37b61b
Revert "Enhance Google Analytics integration in head.liquid by adding…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,152 @@ | ||
| {%- if settings.measurementId and settings.measurementId.size > 0 -%} | ||
| {%- assign measurementChar = settings.measurementId | slice: 0 -%} | ||
| {%- assign isNew = measurementChar == "G" -%} | ||
| {%- assign isNew = measurementChar = = "G" -%} | ||
| {%- if isNew -%} | ||
| <script | ||
| async | ||
| src="https://www.googletagmanager.com/gtag/js?id={{ settings.measurementId }}" | ||
| ></script> | ||
| <script> | ||
| window.dataLayer = window.dataLayer || []; | ||
| function gtag() { | ||
| dataLayer.push(arguments); | ||
| } | ||
| gtag('js', new Date()); | ||
| gtag('config', '{{- settings.measurementId -}}', { {% if anonymize %}'anonymize_ip': true,{% endif %} 'send_page_view': false }); | ||
| gtag('set', {'user_id': '{{ member.id }}'}); | ||
| function onPageView(data) { | ||
| gtag('event', 'page_view', { | ||
| page_title: data.title, | ||
| page_path: data.page, | ||
| }); | ||
| } | ||
| if (window.Tribe) { | ||
| window.Tribe.on('pageView', onPageView); | ||
| } | ||
| window.BM.on('ready', () => { | ||
| window.BM.scriptManager.register({ | ||
| name: 'google-analytics', | ||
| consentCategory: 'analytics', | ||
| load: () => { | ||
| // Load script | ||
| const script = document.createElement('script'); | ||
| script.async = true; | ||
| script.src = 'https://www.googletagmanager.com/gtag/js?id=G-123456'; | ||
| document.head.appendChild(script); | ||
|
|
||
| // Initialize Google Analytics | ||
| window.dataLayer = window.dataLayer || []; | ||
| function gtag() { | ||
| dataLayer.push(arguments); | ||
| } | ||
| gtag('js', new Date()); | ||
| gtag('config', '{{- settings.measurementId -}}', { {% if anonymize %}'anonymize_ip': true,{% endif %} 'send_page_view': false }); | ||
| gtag('set', { | ||
| 'user_id': '{{- member.id -}}' | ||
| }); | ||
|
|
||
|
|
||
| // Listen for page views | ||
| function onPageView(data) { | ||
| gtag('event', 'page_view', { | ||
| page_title: data.title, | ||
| page_path: data.page, | ||
| }); | ||
| } | ||
| if (window.Tribe) { | ||
| window.ga4PageViewListener = window.Tribe.on('pageView', onPageView); | ||
| } | ||
| }, | ||
| unload: () => { | ||
| // Remove script | ||
| const script = document.querySelector('script[src*="googletagmanager.com/gtag/js"]'); | ||
| if (script) { | ||
| script.remove(); | ||
| } | ||
|
|
||
| // Remove dataLayer | ||
| window.dataLayer = undefined; | ||
|
|
||
| // Remove page view listener | ||
| if (window.ga4PageViewListener) { | ||
| window.ga4PageViewListener.removeAllListeners(); | ||
| window.ga4PageViewListener = undefined; | ||
| } | ||
| }, | ||
| getCookiesToRemove: () => { | ||
| const getCookieOptions = () => { | ||
| try { | ||
| const domainParts = window.location.hostname.split('.') | ||
| const removalDomain = `.${domainParts.slice(-2).join('.')}` | ||
| return { domain: removalDomain, path: '/' } | ||
| } catch { | ||
| return { domain: window.location.hostname, path: '/' } | ||
| } | ||
| } | ||
| const options = getCookieOptions() | ||
| return [ | ||
| { name: '_ga', options }, | ||
| { name: '_ga_{{ settings.measurementId }}', options }, | ||
| ] | ||
| }, | ||
| }) | ||
| }); | ||
| </script> | ||
| {%- endif -%} {%- unless isNew -%} | ||
| {%- endif -%} | ||
| {%- unless isNew -%} | ||
| <script> | ||
| (function(i, s, o, g, r, a, m) { | ||
| i['GoogleAnalyticsObject'] = r; | ||
| i[r] = i[r] || function() { | ||
| (i[r].q = i[r].q || []).push(arguments) | ||
| }, i[r].l = 1 * new Date(); | ||
| a = s.createElement(o), | ||
| m = s.getElementsByTagName(o)[0]; | ||
| a.async = 1; | ||
| a.src = g; | ||
| m.parentNode.insertBefore(a, m) | ||
| })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); | ||
| window.BM.on('ready', () => { | ||
| window.BM.scriptManager.register({ | ||
| name: 'google-analytics-legacy', | ||
| consentCategory: 'analytics', | ||
| load: () => { | ||
| // Load script | ||
| (function(i, s, o, g, r, a, m) { | ||
| i['GoogleAnalyticsObject'] = r; | ||
| i[r] = i[r] || function() { | ||
| (i[r].q = i[r].q || []).push(arguments) | ||
| }, i[r].l = 1 * new Date(); | ||
| a = s.createElement(o), | ||
| m = s.getElementsByTagName(o)[0]; | ||
| a.async = 1; | ||
| a.src = g; | ||
| m.parentNode.insertBefore(a, m) | ||
| })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); | ||
|
|
||
| // Initialize Google Analytics | ||
| ga('create', '{{ settings.measurementId }}', 'auto'); | ||
| {% if anonymize -%} | ||
| ga('set', 'anonymizeIp', true); | ||
| {% endif -%} | ||
|
|
||
| ga('set', 'userId', '{{ member.id }}'); | ||
|
|
||
| // Listen for page views | ||
| const onPageView = (data) => { | ||
| ga('send', { | ||
| 'hitType': 'pageview', | ||
| 'page': data.page, | ||
| 'title': data.title, | ||
| }); | ||
| } | ||
| if (window.Tribe) { | ||
| window.ga4PageViewListener = window.Tribe.on('pageView', onPageView); | ||
| } | ||
| }, | ||
| unload: () => { | ||
| // Remove script | ||
| const script = document.querySelector('script[src*="google-analytics.com/analytics.js"]'); | ||
| if (script) { | ||
| script.remove(); | ||
| } | ||
|
|
||
| // Remove dataLayer | ||
| window.dataLayer = undefined; | ||
|
|
||
| ga('create', '{{ settings.measurementId }}', 'auto'); | ||
| {% if anonymize -%} | ||
| ga('set', 'anonymizeIp', true); | ||
| {% endif -%} | ||
| ga('set', 'userId', '{{ member.id }}'); | ||
| function onPageView(data) { | ||
| ga('send', { | ||
| 'hitType': 'pageview', | ||
| 'page': data.page, | ||
| 'title': data.title, | ||
| }); | ||
| } | ||
| if (window.Tribe) { | ||
| window.Tribe.on('pageView', onPageView); | ||
| } | ||
| // Remove page view listener | ||
| if (window.ga4PageViewListener) { | ||
| window.ga4PageViewListener.removeAllListeners(); | ||
| window.ga4PageViewListener = undefined; | ||
| } | ||
| }, | ||
| getCookiesToRemove: () => { | ||
| const getCookieOptions = () => { | ||
| try { | ||
| const domainParts = window.location.hostname.split('.') | ||
| const removalDomain = `.${domainParts.slice(-2).join('.')}` | ||
| return { domain: removalDomain, path: '/' } | ||
| } catch { | ||
| return { domain: window.location.hostname, path: '/' } | ||
| } | ||
| } | ||
| const options = getCookieOptions() | ||
| return [ | ||
| { name: '_ga', options }, | ||
| { name: '_ga_{{ settings.measurementId }}', options }, | ||
| ] | ||
| } | ||
| }) | ||
| }) | ||
| </script> | ||
| {%- endunless -%} | ||
| {%- endif -%} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.