summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiderr <spiderr@bitweaver.org>2023-11-26 18:46:15 -0500
committerspiderr <spiderr@bitweaver.org>2023-11-26 18:46:15 -0500
commitd4176e9761ac6fe8eba398f731880d1db80d30db (patch)
tree0e68eb59c84be1ee0303011b91f2c695f75afcc1
parent10b696edc5aedba5203f52d5e66d7bd068bb06fc (diff)
downloadstats-d4176e9761ac6fe8eba398f731880d1db80d30db.tar.gz
stats-d4176e9761ac6fe8eba398f731880d1db80d30db.tar.bz2
stats-d4176e9761ac6fe8eba398f731880d1db80d30db.zip
update *_anayltics_ naming; add support for google_tagmanager_id; clean up admin
-rw-r--r--admin/admin_stats_inc.php30
-rw-r--r--templates/admin_stats.tpl33
-rw-r--r--templates/footer_inc.tpl4
-rw-r--r--templates/html_head_inc.tpl10
4 files changed, 42 insertions, 35 deletions
diff --git a/admin/admin_stats_inc.php b/admin/admin_stats_inc.php
index 48d40e7..61a2dbc 100644
--- a/admin/admin_stats_inc.php
+++ b/admin/admin_stats_inc.php
@@ -1,15 +1,31 @@
<?php
-$formFeaturesBit['stats_referers'] = array(
- 'label' => 'Referer Statistics',
- 'note' => 'Records statistics including HTTP_REFERRER',
+$formFeaturesBit = array(
+ 'stats_referers' => array(
+ 'label' => 'Referer Statistics',
+ 'note' => 'Records statistics including HTTP_REFERRER',
+ ),
+ 'google_tagmanager_id' => array(
+ 'label' => "Google TagManager Container ID for GA4",
+ 'type' => "text",
+ 'note' => "TagManager Container ID, which should be conected to your GA4 measurement ID; e.g. GTM-ABCD1234 See from https://tagmanager.google.com",
+ ),
+ 'google_analytics_ua' => array(
+ 'label' => "Google Analytics UA (DISCONTINUED)",
+ 'type' => "text",
+ 'note' => "UA from anayltics.google.com; discontinued June 30, 2023",
+ ),
+ 'microsoft_analytics_ti' => array(
+ 'label' => "Microsoft Analytics TI",
+ 'type' => "text",
+ 'note' => "TI from ads.microsoft.com conversion javascript",
+ ),
);
+
$gBitSmarty->assign( 'formFeaturesBit', $formFeaturesBit );
if( !empty( $_REQUEST['change_prefs'] ) ) {
- foreach( $formFeaturesBit as $item => $info ) {
- simple_set_toggle( $item, STATS_PKG_NAME );
+ foreach ( array_keys( $formFeaturesBit ) as $feature) {
+ $gBitSystem->storeConfig( $feature, (isset( $_REQUEST[$feature] ) ? $_REQUEST[$feature] : NULL), STATS_PKG_NAME );
}
- $gBitSystem->storeConfig( 'analytics_google_ua', BitBase::getParameter( $_REQUEST, 'analytics_google_ua' ) );
- $gBitSystem->storeConfig( 'analytics_microsoft_ti', BitBase::getParameter( $_REQUEST, 'analytics_microsoft_ti' ) );
}
diff --git a/templates/admin_stats.tpl b/templates/admin_stats.tpl
index 4c5e5f2..7121a6f 100644
--- a/templates/admin_stats.tpl
+++ b/templates/admin_stats.tpl
@@ -3,29 +3,20 @@
{form legend="Statistics Settings"}
<input type="hidden" name="page" value="{$page}" />
- <div class="form-group">
- {formlabel label="Google Analytics UA" for="analytics_google_ua"}
- {forminput}
- <input type="text" class="form-control" name="analytics_google_ua" id="analytics_google_ua" value="{$gBitSystem->getConfig('analytics_google_ua')|escape}" />
- {formhelp note="UA from anayltics.google.com"}
- {/forminput}
- </div>
-
- <div class="form-group">
- {formlabel label="Microsoft Analytics TI" for="analytics_microsoft_ti"}
- {forminput}
- <input type="text" class="form-control" name="analytics_microsoft_ti" id="analytics_microsoft_ti" value="{$gBitSystem->getConfig('analytics_microsoft_ti')|escape}" />
- {formhelp note="TI from ads.microsoft.com conversion javascript"}
- {/forminput}
- </div>
-
{foreach from=$formFeaturesBit key=feature item=output}
<div class="form-group">
- {formlabel label=$output.label for=$feature}
- {forminput label="checkbox"}
- {html_checkboxes name="$feature" values="y" checked=$gBitSystem->getConfig($feature) labels=false id=$feature}
- {formhelp note=$output.note page=$output.page}
- {/forminput}
+ {if $output.type == 'text'}
+ {forminput}
+ {formlabel label=$output.label for=$feature}
+ <input type="text" class="form-control" name="{$feature}" id="{$feature}" value="{$gBitSystem->getConfig($feature)|escape}" />
+ {formhelp note=$output.note page=$output.page link=$output.link}
+ {/forminput}
+ {else}
+ {forminput label="checkbox"}
+ {html_checkboxes name="$feature" values="y" checked=$gBitSystem->getConfig($feature) labels=false id=$feature} {tr}{$output.label}{/tr}
+ {formhelp note=$output.note page=$output.page link=$output.link}
+ {/forminput}
+ {/if}
</div>
{/foreach}
diff --git a/templates/footer_inc.tpl b/templates/footer_inc.tpl
index d04da7d..ad78376 100644
--- a/templates/footer_inc.tpl
+++ b/templates/footer_inc.tpl
@@ -6,7 +6,7 @@
{/if}
{* **** MICROSOFT ANALYTICS **** *}
-{if $gBitSystem->getConfig('analytics_microsoft_ti')}
-<noscript><img src="//bat.bing.com/action/0?ti={$gBitSystem->getConfig('analytics_microsoft_ti')}&Ver=2" height="0" width="0" style="display:none; visibility: hidden;" alt="."></noscript>
+{if $gBitSystem->getConfig('microsoft_analytics_ti')}
+<noscript><img src="//bat.bing.com/action/0?ti={$gBitSystem->getConfig('microsoft_analytics_ti')}&Ver=2" height="0" width="0" style="display:none; visibility: hidden;" alt="."></noscript>
{/if}
diff --git a/templates/html_head_inc.tpl b/templates/html_head_inc.tpl
index 787847c..5784999 100644
--- a/templates/html_head_inc.tpl
+++ b/templates/html_head_inc.tpl
@@ -25,13 +25,13 @@
{* **** GOOGLE UNIVERSAL ANALYTICS **** *}
<!-- Google Univeral Analytics -->
- {if $gBitSystem->getConfig('analytics_google_ua')}
-<script async src="https://www.googletagmanager.com/gtag/js?id={$gBitSystem->getConfig('analytics_google_ua')}"></script>
+ {if $gBitSystem->getConfig('google_analytics_ua')}
+<script async src="https://www.googletagmanager.com/gtag/js?id={$gBitSystem->getConfig('google_analytics_ua')}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ldelim}dataLayer.push(arguments);{rdelim}
gtag('js', new Date());
- gtag('config', '{$gBitSystem->getConfig('analytics_google_ua')}');
+ gtag('config', '{$gBitSystem->getConfig('google_analytics_ua')}');
{if $gBitUser->isRegistered()}gtag('set', {ldelim}'user_id': '{$gBitUser->mUserId}'{rdelim});{/if}
</script>
{/if}
@@ -39,8 +39,8 @@
{/if}
{* **** MICROSOFT ANALYTICS **** *}
-{if $gBitSystem->getConfig('analytics_microsoft_ti')}{literal}
-<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"{/literal}{$gBitSystem->getConfig('analytics_microsoft_ti')}{literal}"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");</script>
+{if $gBitSystem->getConfig('microsoft_analytics_ti')}{literal}
+<script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"{/literal}{$gBitSystem->getConfig('microsoft_analytics_ti')}{literal}"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function(){var s=this.readyState;s&&s!=="loaded"&&s!=="complete"||(f(),n.onload=n.onreadystatechange=null)},i=d.getElementsByTagName(t)[0],i.parentNode.insertBefore(n,i)})(window,document,"script","//bat.bing.com/bat.js","uetq");</script>
{/literal}{/if}
{/strip}