Plugin Directory

Changeset 3170069


Ignore:
Timestamp:
10/16/2024 11:04:37 AM (16 months ago)
Author:
wiredmindshelp
Message:

Updated from GitLab CI 1.6.1

Location:
ip2ga/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ip2ga/trunk/README.txt

    r3166670 r3170069  
    66Tested up to: 6.6 
    77Requires PHP: 7.4 
    8 Stable tag: 1.6 
     8Stable tag: 1.6.1 
    99License: GPLv2 or later 
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html 
     
    60602. Go to the **Admin** section (gear icon at the bottom left).
    61613. Under the Account column, select your account or create a new one if you don't have it.
    62 4. In the top left, click + **Create Property**.
    63 5. Follow the steps to set up your new property. Make sure to select **Other** as the business objective during the setup.
     624. In the top left, click + **Create Property** or use existing Property .
     635. Follow the steps to set up your  **only for new property**. Make sure to select **All** as the business objective during the setup.
    64646. Note down the **Measurement ID** (it starts with "G-").
    65657. Click on **Measurement Protocol API secrets** and create a new secret. Name it, and then copy the **API Secret**.
     
    211211Ensure that your marketing URLs include UTM parameters. The plugin will automatically capture and send these parameters to GA4, allowing you to track the performance of your campaigns directly in Google Analytics.
    212212
     213= I detected a provider / ISP - how can I hide them? =
     214
     215Here is a link where you can report providers, which will be hidden from our side. :[Tracking – Providercheck](https://help.wiredminds.de/tracking-providercheck/).
     216
    213217== Screenshots ==
    214218
     
    216220
    217221== Changelog ==
     222
     223= 1.6.1 =
     224* Updated AJAX tracking for link click event.
     225* Added company name check before sending to GA4.
    218226
    219227= 1.6 =
  • ip2ga/trunk/admin-script.js

    r3166670 r3170069  
    3030        }
    3131    }
     32
     33    // Initial nav-tab
     34    $('.nav-tab').on('click', function(e) {
     35        e.preventDefault();
     36        $('.nav-tab').removeClass('nav-tab-active');
     37        $(this).addClass('nav-tab-active');
     38        $('.tab-content').hide();
     39        $($(this).attr('href')).show();
     40    });
     41
     42    // Show Consent Settings only when GA4 Tracking Code is enabled
     43    $('#enable_ga_tracking').on('change', function() {
     44        if ($(this).is(':checked')) {
     45            $('a[href="#consent-settings"]').show();
     46        } else {
     47            $('a[href="#consent-settings"]').hide();
     48            $('#consent-settings').hide();
     49        }
     50     }).trigger('change'); // Trigger change on page load to ensure correct state
     51
    3252});
  • ip2ga/trunk/ip2ga-event-tracking.js

    r3166670 r3170069  
    114114    // Event handler for general link clicks
    115115    $('a').on('click', function(event) {
    116         event.preventDefault();
    117 
    118         var eventData = {
    119             action: 'ga_ip2c_event',
    120             type: 'link_click',
    121             category: 'Link Click',
    122             label: $(this).text() || $(this).attr('href'),
    123             page: window.location.pathname,
    124             title: document.title,
    125             additional: {
    126                 url: $(this).attr('href')
    127             }
    128         };
    129 
    130         enqueueRequest({
    131             url: ga_ip2c_ajax.ajax_url,
    132             method: 'POST',
    133             data: $.extend(eventData, { security: ga_ip2c_ajax.nonce }),
    134             success: function() {
    135                 window.location.href = eventData.additional.url; // Redirect after tracking
    136             },
    137             error: function() {
    138                 window.location.href = eventData.additional.url; // Redirect even on error
    139             }
    140         });
     116        var href = $(this).attr('href');
     117        if (href && href.startsWith('#')) {
     118            // Track the click on the anchor link
     119            var eventData = {
     120                action: 'ga_ip2c_event',
     121                type: 'anchor_click',
     122                category: 'Anchor Link Click',
     123                label: $(this).text() || href,
     124                page: window.location.pathname,
     125                title: document.title,
     126                additional: {
     127                    anchor: href
     128                }
     129            };
     130           
     131            enqueueRequest({
     132                url: ga_ip2c_ajax.ajax_url,
     133                method: 'POST',
     134                data: $.extend(eventData, { security: ga_ip2c_ajax.nonce })
     135            });
     136
     137
     138        }
     139        else if (href && href.match(/\.(pdf|docx|xlsx|zip|rar|jpg|png)$/i)) {
     140            // Prevent default behavior to allow tracking before redirecting           
     141            event.preventDefault();
     142
     143            // Track the click on file downloads
     144            var eventData = {
     145                action: 'ga_ip2c_event',
     146                type: 'download',
     147                category: 'Download',
     148                label: href,
     149                page: window.location.pathname,
     150                title: document.title
     151            };
     152
     153            enqueueRequest({
     154                url: ga_ip2c_ajax.ajax_url,
     155                method: 'POST',
     156                data: $.extend(eventData, { security: ga_ip2c_ajax.nonce }),
     157                success: function() {
     158                    window.location.href = href; // Redirect after tracking
     159                },
     160                error: function() {                   
     161                    window.location.href = href; // Redirect even on error
     162                }
     163            });
     164        }
     165        else {
     166            // Prevent default behavior to allow tracking before redirecting           
     167            event.preventDefault();
     168           
     169            // Track the click on general links
     170            var eventData = {
     171                action: 'ga_ip2c_event',
     172                type: 'link_click',
     173                category: 'Link Click',
     174                label: $(this).text() || href,
     175                page: window.location.pathname,
     176                title: document.title,
     177                additional: {
     178                    url: href
     179                }
     180            };
     181
     182            enqueueRequest({
     183                url: ga_ip2c_ajax.ajax_url,
     184                method: 'POST',
     185                data: $.extend(eventData, { security: ga_ip2c_ajax.nonce }),
     186                success: function() {
     187                    window.location.href = href; // Redirect after tracking
     188                },
     189                error: function() {
     190                    window.location.href = href; // Redirect even on error
     191                }
     192            });
     193        }           
    141194    });
    142195
     
    218271    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    219272
    220     // Event handler for file downloads
    221     $('a').on('click', function(event) {
    222         var href = $(this).attr('href');
    223         if (href && href.match(/\.(pdf|docx|xlsx|zip|rar|jpg|png)$/i)) {
    224             var eventData = {
    225                 action: 'ga_ip2c_event',
    226                 type: 'download',
    227                 category: 'Download',
    228                 label: href,
    229                 page: window.location.pathname,
    230                 title: document.title
    231             };
    232 
    233             enqueueRequest({
    234                 url: ga_ip2c_ajax.ajax_url,
    235                 method: 'POST',
    236                 data: $.extend(eventData, { security: ga_ip2c_ajax.nonce })
    237             });
    238         }
    239     });
     273
     274
    240275
    241276    // Other event handlers can be added here
  • ip2ga/trunk/ip2ga-plugin.php

    r3166670 r3170069  
    33Plugin Name: IP2GA
    44Description: Track all user activities on the site, including page views, button clicks, and form submissions, and send them to Google Analytics 4.
    5 Version: 1.6
     5Version: 1.6.1
    66Author: Wiredminds GmbH
    77Author URI: https://wiredminds.de
     
    154154// Function to send data to Google Analytics 4
    155155function ip2ga_send_data_to_ga($data, $event_data) {
     156
     157    // If company_name is empty, do not send data
     158    if (empty($data['name'])) {
     159        return;
     160    }
     161
    156162    $tracking_id = get_option('ga_ip2c_ga_id');
    157163    $api_secret = get_option('ga_ip2c_api_secret');
     
    421427function ip2ga_settings_page() {
    422428    ?>
    423     <div class="wrap">
    424         <h1>IP2GA Integration Settings</h1>
    425         <form method="post" action="options.php">
    426             <?php settings_fields('ga_ip2c_settings_group'); ?>
    427             <?php do_settings_sections('ga_ip2c_settings_group'); ?>
     429<div class="wrap">
     430    <h1>IP2GA Integration Settings</h1>
     431    <h2 class="nav-tab-wrapper">
     432        <a href="#general-settings" class="nav-tab nav-tab-active">General Settings</a>
     433        <a href="#tracking-settings" class="nav-tab">Tracking Settings</a>
     434        <a href="#consent-settings" class="nav-tab" style="display: none;">Consent Settings</a>
     435    </h2>
     436    <form method="post" action="options.php">
     437        <?php settings_fields('ga_ip2c_settings_group'); ?>
     438        <?php do_settings_sections('ga_ip2c_settings_group'); ?>
     439       
     440        <!-- General Settings Tab -->
     441        <div id="general-settings" class="tab-content" style="display: block;">
    428442            <table class="form-table">
    429443                <tr valign="top">
     
    431445                    <td>
    432446                      <input id="rapidapi_token" type="text" name="ga_ip2c_rapid_token" value="<?php echo esc_attr(get_option('ga_ip2c_rapid_token')); ?>" />
    433                       <p>Enter your RapidAPI Token. If you fill this field, leave the <b>WiredMinds API Token</b> field empty.</p>
     447                      <p>Enter your <a href="https://rapidapi.com/wiredminds-gmbh-wiredminds-gmbh-default/api/ip2company3" target="_blank"><b>RapidAPI Token</b></a>. If you fill this field, leave the <b>WiredMinds API Token</b> field empty.</p>
     448                    </td>
     449                </tr>
     450                <tr valign="top">
     451                    <th scope="row"><span class="dashicons dashicons-rest-api"></span> WiredMinds API Token</th>
     452                    <td>
     453                      <input id="ip2c_token" type="text" name="ga_ip2c_token" value="<?php echo esc_attr(get_option('ga_ip2c_token')); ?>" />
     454                      <p>Enter the API Token provided by WiredMinds GmbH. If you fill this field, leave the <b>RapidAPI Token</b> field empty.</p>
    434455                    </td>
    435456                </tr>
     
    448469                    </td>
    449470                </tr>
     471            </table>
     472        </div>
     473       
     474        <!-- Tracking Settings Tab -->
     475        <div id="tracking-settings" class="tab-content" style="display: none;">
     476            <table class="form-table">
    450477                <tr valign="top">
    451478                    <th scope="row"><span class="dashicons dashicons-welcome-view-site"></span> Enable AJAX Event Tracking</th>
    452479                    <td>
    453480                      <input type="checkbox" name="ga_ip2c_enable_ajax_tracking" value="1" <?php checked(1, get_option('ga_ip2c_enable_ajax_tracking'), true); ?> />
    454                       <p>Enable or disable event tracking via AJAX requests.</p>
     481                      <p>Enable JavaScript to track GA4 events if a visitor rejects cookies.</p>
    455482                    </td>
    456483                </tr>
     
    458485                    <th scope="row"><span class="dashicons dashicons-visibility"></span> Enable GA4 Tracking Code</th>
    459486                    <td>
    460                       <input type="checkbox" name="ga_ip2c_enable_ga_tracking" value="1" <?php checked(1, get_option('ga_ip2c_enable_ga_tracking'), true); ?> />
    461                       <p>Enable or disable embedding the GA4 tracking script on your site.</p>
    462                     </td>
    463                 </tr>               
    464                 <tr valign="top">
    465                     <th scope="row"><span class="dashicons dashicons-rest-api"></span> WiredMinds API Token</th>
    466                     <td>
    467                       <input id="ip2c_token" type="text" name="ga_ip2c_token" value="<?php echo esc_attr(get_option('ga_ip2c_token')); ?>" />
    468                       <p>Enter the API Token provided by WiredMinds GmbH. If you fill this field, leave the <b>RapidAPI Token</b> field empty.</p>
    469                     </td>
    470                 </tr>
     487                      <input id="enable_ga_tracking" type="checkbox" name="ga_ip2c_enable_ga_tracking" value="1" <?php checked(1, get_option('ga_ip2c_enable_ga_tracking'), true); ?> />
     488                      <p>Enable GA4 tracking only if you're not using other methods to add Google Analytics or Tag Manager code.</p>
     489                    </td>
     490                </tr>
     491            </table>
     492        </div>
     493
     494        <!-- Consent Settings Tab -->
     495        <div id="consent-settings" class="tab-content" style="display: none;">
     496            <table class="form-table">
    471497                <tr valign="top">
    472498                    <th scope="row"><span class="dashicons dashicons-format-aside"></span> Consent Banner Text</th>
     
    482508                        <p>Enter the URL of your privacy policy page (e.g., <code>/privacy-policy</code>).</p>
    483509                    </td>
    484                 </tr>               
     510                </tr>
    485511            </table>
     512        </div>
     513
    486514            <?php submit_button(); ?>
    487515        </form>
Note: See TracChangeset for help on using the changeset viewer.