Plugin Directory

Changeset 2201674


Ignore:
Timestamp:
11/26/2019 11:08:01 PM (6 years ago)
Author:
thetinydesk
Message:

Adding google maps and telephone conversion pixel tracking events

Location:
tiny-desk-pixel/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tiny-desk-pixel/trunk/public/class-tiny-desk-pixel-public.php

    r2131092 r2201674  
    9898
    9999        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/tiny-desk-pixel-public.js', array( 'jquery' ), $this->version, false );
     100
     101        $advertiserId = get_option('tiny-desk-advertiser-id');
     102        $pixelId = get_option('tiny-desk-pixel-id');
     103        $ttdConfig = array( 'advertiserId' => $advertiserId, 'pixelId' => $pixelId );
     104
     105        wp_localize_script( $this->plugin_name, 'ttdConfig', $ttdConfig );
    100106    }
    101107
  • tiny-desk-pixel/trunk/public/js/tiny-desk-pixel-public.js

    r2106481 r2201674  
    11(function( $ ) {
    22    'use strict';
    3 
    4     /**
    5      * All of the code for your public-facing JavaScript source
    6      * should reside in this file.
    7      *
    8      * Note: It has been assumed you will write jQuery code here, so the
    9      * $ function reference has been prepared for usage within the scope
    10      * of this function.
    11      *
    12      * This enables you to define handlers, for when the DOM is ready:
    13      *
    14      * $(function() {
    15      *
    16      * });
    17      *
    18      * When the window is loaded:
    19      *
    20      * $( window ).load(function() {
    21      *
    22      * });
    23      *
    24      * ...and/or other possibilities.
    25      *
    26      * Ideally, it is not considered best practise to attach more than a
    27      * single DOM-ready or window-load handler for a particular page.
    28      * Although scripts in the WordPress core, Plugins and Themes may be
    29      * practising this, we should strive to set a better example in our own work.
    30      */
     3    function clickListener(event) {
     4        if(event.target.tagName.toLowerCase() === 'a') {
     5            const href = event.target.href;
     6            const telRegex = /^tel:/g;
     7            const mapRegex = /(goo.gl|google.com)\/maps\//;
     8            if((telRegex.test(href) || mapRegex.test(href)) && typeof TTDUniversalPixelApi === "function") {
     9                var universalPixelApi = new TTDUniversalPixelApi(`contact_${telRegex.test(href) ? 'tel' : 'map'}`);
     10                universalPixelApi.init(ttdConfig.advertiserId, [ttdConfig.pixelId], "https://insight.adsrvr.org/track/up");
     11            }
     12        }
     13    }
     14    $( window ).load(function() {
     15        document.body.addEventListener('click', clickListener, true);
     16    });
    3117
    3218})( jQuery );
  • tiny-desk-pixel/trunk/tiny-desk-pixel.php

    r2131092 r2201674  
    1515 * Plugin URI:        www.thetradedesk.com
    1616 * Description:       It helps you add easily your tracking tag from Tiny Desk by just giving your advertiser id and pixel id.
    17  * Version:           1.0.2
     17 * Version:           1.0.3
    1818 * Author:            The Trade Desk
    1919 * Author URI:        https://profiles.wordpress.org/thetinydesk/
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define( 'TINY_DESK_PIXEL_VERSION', '1.0.2' );
     36define( 'TINY_DESK_PIXEL_VERSION', '1.0.3' );
    3737
    3838/**
Note: See TracChangeset for help on using the changeset viewer.