Plugin Directory

Changeset 2899799


Ignore:
Timestamp:
04/16/2023 05:44:35 PM (3 years ago)
Author:
vaksin
Message:
  • Add WA Form ability to send event to GTM and FB Pixel
Location:
express-add-on
Files:
150 added
4 edited

Legend:

Unmodified
Added
Removed
  • express-add-on/trunk/modules/whatsapp/assets/front/js/wa-form.js

    r2862890 r2899799  
    1717    //available WA fields in Form
    1818    let WAFields;
     19
     20    //Submit button in Form
     21    let WASubmitButton;
     22
     23    //Submit button ID prefix
     24    const WASubmitButtonId = 'wa_send_';
    1925
    2026    if (document.readyState !== 'loading') {
     
    6369            }
    6470
     71            WASubmitButton = WAPopUp.element.querySelector('button[type="submit"]');
     72
     73            WASubmitButton.id = WASubmitButtonId;
     74
    6575            WAForm.onsubmit = onFormSubmit;
    6676           
     
    104114        }
    105115
     116        if (typeof window.dataLayer === 'object') {
     117            window.dataLayer.push({
     118                'event': 'wa_send',
     119                'id': WASubmitButton.id,
     120                'name': WAFields.name.value,
     121                'phone': WAFields.phone.value,
     122                'email': WAFields.email.value,
     123                'text': WAFields.text.value,
     124            });
     125        }
     126
     127        if (typeof fbq === 'function') {
     128            fbq('trackCustom', 'WASend', {
     129                'id': WASubmitButton.id,
     130                'name': WAFields.name.value,
     131                'phone': WAFields.phone.value,
     132                'email': WAFields.email.value,
     133                'text': WAFields.text.value,
     134            });   
     135        }
     136
    106137        openWhatsApp(WAFields.text.value);
    107138        WAPopUp.close();       
     
    124155        }
    125156
    126         if ( (WAFields.phone.value !== '')  && (text_value.indexOf('{email}') !== -1) ) {
    127             text_value = text_value.replace('{email}', WAFields.phone.value);
     157        if ( (WAFields.email.value !== '')  && (text_value.indexOf('{email}') !== -1) ) {
     158            text_value = text_value.replace('{email}', WAFields.email.value);
    128159        }
    129160       
     
    133164    function clickWhatsAppLink(event){
    134165        event.preventDefault();
    135        
     166               
    136167        let queryString = event.currentTarget.href.split('?')[1];
    137168        const wa_params = new URLSearchParams(queryString);
     169
     170        const clickID = event.currentTarget.hasAttribute('id') ? event.currentTarget.id : '';
    138171
    139172        WATextTemplate = _vxn_data_vxn_wa_form.text_default;
     
    143176        }   
    144177       
     178        if (typeof window.dataLayer === 'object') {
     179            window.dataLayer.push({
     180                'event': 'wa_clicked',
     181                'id': clickID,
     182                'href': event.currentTarget.href
     183            });
     184        }
     185
     186        if (typeof fbq === 'function') {
     187            fbq('trackCustom', 'WAClicked',{         
     188                'id': clickID,
     189                'href': event.currentTarget.href
     190            });   
     191        }
     192
    145193        if(WAFormReady) {
     194           
     195            WASubmitButton.id = WASubmitButtonId + clickID;
     196           
    146197            updateWaTextValue();
    147198            WAPopUp.open();
  • express-add-on/trunk/modules/whatsapp/whatsapp-popup.php

    r2862890 r2899799  
    1717            $script = (New Script('vxn_wa_form', VXN_EXPRESS_WHATSAPP_URL . '/assets/front/js/wa-form.js'))
    1818                        ->set_data(array(self::class, 'script_data'))
    19                         ->set_ver('1.0.4');         
     19                        ->set_ver('1.0.5');         
    2020            Express::add_script($script);
    2121        }
  • express-add-on/trunk/readme.txt

    r2894438 r2899799  
    66Tested up to: 6.1.1
    77Requires PHP: 7.4
    8 Stable tag: 1.3.3
     8Stable tag: 1.3.4
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    5555
    5656== Changelog ==
     57= 1.3.4 =
     58
     59* Add WA Form ability to send event to GTM and FB Pixel
     60
    5761= 1.3.3 =
    5862
  • express-add-on/trunk/vxn-express.php

    r2894438 r2899799  
    44 * Plugin URI:        https://github.com/wp-vaksin/vxn-express
    55 * Description:       Express Add-on for Breakdance website builder, the time saver plugin!
    6  * Version:           1.3.3
     6 * Version:           1.3.4
    77 * Requires at least: 5.2
    88 * Requires PHP:      8.0
     
    1414 * Domain Path:       /languages
    1515 */
    16 
    17 use VXN\Express\Helper\Util;
    1816
    1917// If this file is called directly, abort.
Note: See TracChangeset for help on using the changeset viewer.