Plugin Directory

Changeset 3443863


Ignore:
Timestamp:
01/21/2026 09:04:36 AM (7 weeks ago)
Author:
metriondev
Message:

TikTok and cookie confirm cap

Location:
metrion
Files:
67 added
7 edited

Legend:

Unmodified
Added
Removed
  • metrion/trunk/includes/initial.php

    r3382453 r3443863  
    635635        'google_analytics_enable_tracking' => get_option('metrion_google_analytics_enable_tracking', 0),
    636636        'google_analytics_measurement_id' => get_option('metrion_google_analytics_measurement_id', ''),
    637         'google_analytics_api_secret' => get_option('metrion_google_analytics_api_secret', '')
     637        'google_analytics_api_secret' => get_option('metrion_google_analytics_api_secret', ''),
     638        'tiktok_enable_front_end_tracking' => get_option('metrion_tiktok_enable_front_end_tracking', ''),
     639        'tiktok_pixel_id' => get_option('metrion_tiktok_pixel_id', ''),
     640        'tiktok_test_event_code' => get_option('metrion_tiktok_test_event_code', '')
    638641    ]);
    639642}
  • metrion/trunk/includes/js_bundler.php

    r3382453 r3443863  
    124124    }
    125125
     126    // Google Analytics extra events
     127    if (strlen(get_option('metrion_google_analytics_measurement_id', '')) > 1 && !get_option('metrion_purchase_only_tracking', true)) {
     128        $source_files[] = $plugin_dir . 'js/google_analytics/events.js';
     129    }
     130
    126131    // Ensure output directory exists
    127132    if (!$wp_filesystem->is_dir($output_dir)) {
     
    219224    }
    220225
     226
    221227    // Channel JS
    222228    if (get_option('metrion_google_enable_tracking', false)) {
     
    230236    if (get_option('metrion_meta_allow_front_end_pixel_tracking', false)) {
    231237        $source_files[] = $plugin_dir . 'js/meta/events.js';
     238    }
     239
     240    if (get_option('metrion_tiktok_enable_front_end_tracking', false)) {
     241        $source_files[] = $plugin_dir . 'js/tiktok/events.js';
     242    }
     243
     244    // Google Analytics extra events
     245    if (strlen(get_option('metrion_google_analytics_measurement_id', '')) > 1 && !get_option('metrion_purchase_only_tracking', true)) {
     246        $source_files[] = $plugin_dir . 'js/google_analytics/events.js';
    232247    }
    233248
     
    303318    if (get_option('metrion_meta_allow_front_end_pixel_tracking', false)) {
    304319        $source_files[] = $plugin_dir . 'js/meta/events.js';
     320    }
     321   
     322    if (get_option('metrion_tiktok_enable_front_end_tracking', false)) {
     323        $source_files[] = $plugin_dir . 'js/tiktok/events.js';
    305324    }
    306325
  • metrion/trunk/js/core/events.js

    r3382453 r3443863  
    33  configuration: {
    44    init_unix_timestamp: Date.now(),
    5     last_interaction_unix_timestamp_ms: Date.now(),
     5    //last_interaction_unix_timestamp_ms: Date.now(),
    66    cookie_value_separator: "--",
    77    user_cookie_name: metrion_api.user_cookie_name + "_js",
     
    702702    current_stored_event["event_body"]["session_start_time"] =
    703703      window.metrion.session_manager.get_session_cookie_values()[2];
    704     current_stored_event["event_body"]["engaged_time_ms"] =
    705       current_stored_event["event_unix_timestamp"] -
    706       window.metrion.configuration.last_interaction_unix_timestamp_ms;
    707     window.metrion.configuration.last_interaction_unix_timestamp_ms =
    708       current_stored_event["event_unix_timestamp"];
     704    //current_stored_event["event_body"]["engaged_time_ms"] =
     705    //  current_stored_event["event_unix_timestamp"] -
     706    //  window.metrion.configuration.last_interaction_unix_timestamp_ms;
     707    //window.metrion.configuration.last_interaction_unix_timestamp_ms =
     708    //  current_stored_event["event_unix_timestamp"];
    709709
    710710    // Prepare for data sending to API
     
    758758    event_data["event_body"]["session_start_time"] =
    759759      window.metrion.session_manager.get_session_cookie_values()[2];
    760     event_data["event_body"]["engaged_time_ms"] =
    761       event_data["event_unix_timestamp"] -
    762       window.metrion.configuration.last_interaction_unix_timestamp_ms;
     760    //event_data["event_body"]["engaged_time_ms"] =
     761    //  event_data["event_unix_timestamp"] -
     762    //  window.metrion.configuration.last_interaction_unix_timestamp_ms;
    763763
    764764    // Don't reset the engaged time if the event is a non-interaction event
    765     if (
    766       event_data["event_body"].hasOwnProperty("non_interaction") &&
    767       event_data["event_body"]["non_interaction"] !== "1"
    768     ) {
    769       window.metrion.configuration.last_interaction_unix_timestamp_ms =
    770         event_data["event_unix_timestamp"];
    771     }
     765    //if (
     766    // event_data["event_body"].hasOwnProperty("non_interaction") &&
     767    //  event_data["event_body"]["non_interaction"] !== "1"
     768    //) {
     769    //  window.metrion.configuration.last_interaction_unix_timestamp_ms =
     770    //    event_data["event_unix_timestamp"];
     771    //}
    772772
    773773    // If consent cookie is available and floodgate open, handle based on the metrion consent cookie. Otherwise the event will be floodgated later
  • metrion/trunk/js/settings/settings.js

    r3342931 r3443863  
    5050    });
    5151
    52     // Google Analytics options
    53     var google_analytics_button = document.getElementById('google-analytics-settings-toggle');
    54     var google_analytics_settings = document.getElementById('google-analytics-settings');
    55 
    56     google_analytics_button.addEventListener('click', function() {
    57         const isHiddenMetaAds = google_analytics_settings.style.display === 'none';
    58         google_analytics_settings.style.display = isHiddenMetaAds ? 'block' : 'none';
    59         google_analytics_button.textContent = `Google Analytics Configuration Settings ${isHiddenMetaAds ? '▲' : '▼'}`;
    60     });
    6152});
  • metrion/trunk/js/woo/other_events.js

    r3342931 r3443863  
    1010            // Add-to-cart listener
    1111            $("body").on("click", ".add_to_cart_button, .single_add_to_cart_button", function (event) {
     12                var google_analytics_enabled = window.metrion.google_analytics !== undefined;
     13                var event_unix = Date.now();
     14                var engagement_time_msec = 500;               
     15                if(google_analytics_enabled){
     16                    engagement_time_msec = (event_unix - window.metrion.google_analytics.latest_engagement_unix);
     17                }
     18               
    1219                try {
    1320                    var product_id, product_name, product_price, product_regular_price, product_sku, quantity = 1;
     
    7481                        metrion.send_event("add_to_cart", {
    7582                            "items": [product_data],
    76                             "trigger_type": "front-end"
     83                            "trigger_type": "front-end",
     84                            "engaged_time_ms": engagement_time_msec
    7785                        });
    7886                    } else {
  • metrion/trunk/main.php

    r3406662 r3443863  
    33* Plugin Name:          Metrion
    44* Description:          Skip manual implementation, sync data directly tailored to destinations like Google Ads and Meta Ads.
    5 * Version:              1.5.11
     5* Version:              1.5.12
    66* Author:               Metrion
    77* Author URI:           https://getmetrion.com
     
    1212if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    1313
    14 define('GLOBAL_METRION_PLUGIN_VERSION', '1.5.11');
     14define('GLOBAL_METRION_PLUGIN_VERSION', '1.5.12');
    1515
    1616require_once plugin_dir_path(__FILE__) . 'includes/js_bundler.php';
     
    7272    add_option('metrion_meta_test_event_code', '');                                         // Open field for Meta Test event code
    7373
     74    // TikTok Ads destination options
     75    add_option('metrion_tiktok_sync_enabled', 0);                                           // Check whether a TikTok Sync available is
     76    add_option('metrion_tiktok_enable_front_end_tracking', 0);                              // Enable Tiktok Front-end tracking
     77    add_option('metrion_tiktok_pixel_id', '');                                              // Open field for the TikTok Ads pixel ID
     78    add_option('metrion_tiktok_test_event_code', '');                                       // Open field for the TikTok Ads event code
    7479
    7580    // Microsoft Ads destination options
     
    8287    add_option('metrion_google_analytics_enable_tracking', 0);                              // Default setting for enabling Google Analytics
    8388    add_option('metrion_google_analytics_measurement_id', '');                              // Open field for the measurement ID
    84     add_option('metrion_google_analytics_api_secret', '');                                      // Open field for the API key
    85 
    86 
     89    add_option('metrion_google_analytics_api_secret', '');                                  // Open field for the API key
    8790
    8891    // Advanced settings
     
    188191    if ($status_code === 200) {
    189192        $body = json_decode(wp_remote_retrieve_body($response), true);
    190         if (isset($body['active'])) {
     193        if (isset($body['active']) && $body['active'] === true) {
    191194            update_option('metrion_credentials_valid', true);
    192195            update_option('metrion_installation_id', sanitize_text_field($body['installationId']));
     
    211214            update_option('metrion_meta_allow_front_end_pixel_tracking', !empty($pixelId));
    212215            update_option('metrion_meta_pixel_id', $pixelId);
     216
     217            // TikTok Ads settings
     218            $tikTokAdsSync = array_filter($body['syncs'] ?? [], fn($s) => $s['destination'] === 'TikTokAds');
     219            update_option('metrion_tiktok_sync_enabled', in_array('TikTokAds', array_column($body['syncs'], 'destination')));
     220            $pixelId = $tikTokAdsSync ? reset($tikTokAdsSync)['pixelId'] ?? '' : '';
     221            update_option('metrion_tiktok_enable_front_end_tracking', !empty($pixelId));
     222            update_option('metrion_tiktok_pixel_id', $pixelId);
    213223
    214224            // Google Analytics settings
  • metrion/trunk/readme.txt

    r3406662 r3443863  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 1.5.11
     6Stable tag: 1.5.12
    77Requires PHP: 7.1
    88License: GPLv3 or later
     
    6868When Google Ads tracking is activated, this plugin loads and connects with to Google Ads' tracking pixels and APIs. Based on the Google Ads settings in  Metrion's, the user interaction data can be shared with Google Ads.
    6969
    70 Read more about our [terms of use](https://support.google.com/adspolicy/answer/54818?hl=en) and [privacy policy](https://policies.google.com/privacy).
     70Read more about the [terms of use](https://support.google.com/adspolicy/answer/54818?hl=en) and [privacy policy](https://policies.google.com/privacy).
    7171
    7272= Meta Ads Tracking =
    7373When Meta Ads tracking is activated, this plugin loads and connects with to Meta Ads' tracking pixels and APIs. Based on the Meta Ads settings in Metrion's, the user interaction data can be shared with Meta Ads.
    7474
    75 Read more about our [terms of use](https://www.facebook.com/business/direct_terms_ads_en.php) and [privacy policy](https://www.facebook.com/privacy/policy/).
     75Read more about the [terms of use](https://www.facebook.com/business/direct_terms_ads_en.php) and [privacy policy](https://www.facebook.com/privacy/policy/).
    7676
    7777= Microsoft Ads Tracking =
    7878When Microsoft Ads tracking is activated, this plugin loads and connects with to Microsoft Ads' tracking pixels and APIs. Based on the Microsoft Ads settings in Metrion's, the user interaction data can be shared with Microsoft Ads.
    7979
    80 Read more about our [terms of use](https://www.microsoft.com/en/servicesagreement) and [privacy policy](https://www.microsoft.com/en-us/privacy/privacystatement).
     80Read more about the [terms of use](https://www.microsoft.com/en/servicesagreement) and [privacy policy](https://www.microsoft.com/en-us/privacy/privacystatement).
     81
     82= TikTok Ads Tracking =
     83When TikTok Ads tracking is activated, this plugin loads and connects with to TikTok Ads' tracking pixels and APIs. Based on the TikTok Ads settings in Metrion's, the user interaction data can be shared with TikTok Ads.
     84
     85Read more about the [terms, policies and guidelines](https://ads.tiktok.com/i18n/official/policy/terms) and [privacy policy](https://www.tiktok.com/legal/page/us/privacy-policy/en).
    8186
    8287== Screenshots ==
     
    8792
    8893== Changelog ==
     94
     95= 1.5.12 =
     96- Added support for TikTok Ads tracking
     97- Improved controlling of active sync settings
     98- Added suppport for CookieConfirm CMP
     99- Added additional events for engagement time calculation in GA4
    89100
    90101= 1.5.11 =
Note: See TracChangeset for help on using the changeset viewer.