Plugin Directory

Changeset 2895357


Ignore:
Timestamp:
04/07/2023 01:58:49 AM (3 years ago)
Author:
microsoft
Message:

update with SPA tracking

Location:
microsoft-advertising-universal-event-tracking-uet
Files:
7 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • microsoft-advertising-universal-event-tracking-uet/trunk/README.txt

    r2749425 r2895357  
    66Requires PHP: 7.2
    77License: MIT
    8 Stable tag: 1.0.4
     8Stable tag: 1.0.5
    99
    1010The official plugin for setting up Microsoft Advertising UET
     
    2121
    2222== Changelog ==
     23= 1.0.5=
     24* update to support SPA detection
    2325
    2426= 1.0.4=
  • microsoft-advertising-universal-event-tracking-uet/trunk/tagid.php

    r2531528 r2895357  
    11<?php
    22$tagid = '';
     3$enableSpaTracking = '';
    34?>
  • microsoft-advertising-universal-event-tracking-uet/trunk/wp-uet-plugin.php

    r2749425 r2895357  
    77 * Plugin URI: https://ads.microsoft.com/
    88 * Description: The official plugin for setting up Microsoft Advertising UET.
    9  * Version: 1.0.4
     9 * Version: 1.0.5
    1010 * Author: Microsoft Corporation
    1111 * Author URI: https://www.microsoft.com/
     
    1313 */
    1414
    15  // NOTE: If you update 'Version' above, update the 'tm' parameter in the script, around line 42.
     15 // NOTE: If you update 'Version' above, update the 'tm' parameter in the script.
    1616
    1717 //
     
    4141}
    4242
     43function UserSettingForEnableAutoSpaTracking() {
     44    $options = get_option('UetTagSettings');
     45    if(!empty($options['enable_spa_tracking']))
     46    {
     47        $enableSpa_bool = filter_var($options['enable_spa_tracking'], FILTER_VALIDATE_BOOLEAN);
     48        if($enableSpa_bool)
     49        {
     50            return $options['enable_spa_tracking'];
     51        }
     52    }
     53    return 'false';
     54}
     55
    4356function UetPageLoadEvent() {
    4457    if (!UetIsTagAvailable()) return null;
    4558?>
    46         <script>(function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"<?php
    47     $options = get_option('UetTagSettings');
    48     $uet_tag_id = $options['uet_tag_id'];
    49     if (ctype_digit($uet_tag_id)) {
    50         echo esc_attr($uet_tag_id);
    51     }
    52     else{
    53         echo '';
    54     }
    55 ?>",tm:"wpp_1.0.4"};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>
     59        <script>
     60        (function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){
     61            var o={ti:"<?php
     62                $options = get_option('UetTagSettings');
     63                $uet_tag_id = $options['uet_tag_id'];
     64                if (ctype_digit($uet_tag_id)) {
     65                    echo esc_attr($uet_tag_id);
     66                }
     67                else{
     68                    echo '';
     69                }
     70                ?>",
     71                enableAutoSpaTracking: <?php
     72                    echo esc_attr(UserSettingForEnableAutoSpaTracking())
     73                ?>,
     74                tm:"wpp_1.0.5"};
     75            o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},
     76            n=d.createElement(t),n.src=r,n.async=1,n.onload=n.onreadystatechange=function()
     77            {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");
     78        </script>
    5679<?php
    5780  return null;
     
    83106    add_settings_section('uet_general_settings_section', '', 'UetRenderGeneralSettingsSectionHeader', 'uet_tag_settings_page');
    84107    add_settings_field('uet_tag_id', 'UET Tag ID', 'UetEchoTagId', 'uet_tag_settings_page', 'uet_general_settings_section');
     108    add_settings_field('enable_spa_tracking', "Enable SPA Tracking", "UetEchoEnableSpa", 'uet_tag_settings_page', 'uet_general_settings_section');
    85109   
    86110    if(is_admin() && get_option('Activated_Plugin') == 'microsoft-advertising-universal-event-tracking-uet') {
     
    95119            }
    96120        }
    97     }
     121
     122        if(empty($options['enable_spa_tracking'])&& !empty($enableSpaTracking)){
     123            if (filter_var($enableSpaTracking, FILTER_VALIDATE_BOOLEAN)){
     124                    $options['enable_spa_tracking'] = $enableSpaTracking;
     125            }
     126            else
     127            {
     128                    $options['enable_spa_tracking'] = 'false';
     129            }
     130            update_option('UetTagSettings', $options);
     131        }
     132    }
    98133}
    99134
     
    117152}
    118153
     154function UetEchoEnableSpa() {
     155    $options = get_option('UetTagSettings');
     156    $enableSpa = '';
     157    if(isset($options['enable_spa_tracking']) && filter_var($options['enable_spa_tracking'], FILTER_VALIDATE_BOOLEAN)){
     158        $enableSpa = $options['enable_spa_tracking'];
     159        echo "<input id='enable_spa_tracking' name='UetTagSettings[enable_spa_tracking]' type='text' value='" .esc_attr($enableSpa) ."' />";
     160    }
     161    else
     162    {
     163        echo "<input id='enable_spa_tracking' name='UetTagSettings[enable_spa_tracking]' type='text' value='" .esc_attr('false') ."' />";
     164    }
     165}
     166
    119167function UetShowAdminNotice() {
    120168    if (UetIsTagAvailable()) return;
     
    133181    return $links;
    134182}
     183
    135184?>
Note: See TracChangeset for help on using the changeset viewer.