WordPress Landing Pages - Version 1.7.3

Version Description

  • See changelog here: https://github.com/inboundnow/landing-pages/issues?q=is%3Aissue+is%3Aclosed+label%3Av1.7.3
Download this release

Release Info

Developer DavidWells
Plugin Icon 128x128 WordPress Landing Pages
Version 1.7.3
Comparing to
See all releases

Code changes from version 1.7.2 to 1.7.3

Files changed (63) hide show
  1. js/jquery.form-population.js +1 -1
  2. js/page_view_track.js +6 -3
  3. landing-pages.php +2 -2
  4. modules/module.ab-testing.php +18 -16
  5. modules/module.clone.php +1 -1
  6. modules/module.global-settings.php +10 -4
  7. modules/module.install.php +1 -1
  8. modules/module.javascript-frontend.php +1 -2
  9. modules/module.metaboxes-global.php +1 -0
  10. modules/module.redirect-ab-testing.php +12 -4
  11. modules/module.store.php +1 -1
  12. modules/module.templates.php +18 -17
  13. modules/module.track.php +1 -1
  14. readme.txt +5 -2
  15. shared/assets/assets.loader.class.php +22 -6
  16. shared/assets/frontend/js/analytics-src/analytics.events.js +511 -109
  17. shared/assets/frontend/js/analytics-src/analytics.examples.js +185 -0
  18. shared/assets/frontend/js/analytics-src/analytics.forms.js +933 -104
  19. shared/assets/frontend/js/analytics-src/analytics.hooks.js +404 -0
  20. shared/assets/frontend/js/analytics-src/analytics.init.js +121 -32
  21. shared/assets/frontend/js/analytics-src/analytics.lead.js +90 -0
  22. shared/assets/frontend/js/analytics-src/analytics.page.js +361 -0
  23. shared/assets/frontend/js/analytics-src/analytics.start.js +16 -0
  24. shared/assets/frontend/js/analytics-src/analytics.storage.js +19 -22
  25. shared/assets/frontend/js/analytics-src/analytics.utils.js +641 -351
  26. shared/assets/frontend/js/analytics/inboundAnalytics.js +3060 -1179
  27. shared/assets/frontend/js/analytics/inboundAnalytics.min.js +3 -2
  28. shared/assets/frontend/js/inbound.js +839 -0
  29. shared/assets/frontend/js/store.lead.ajax.js +11 -0
  30. shared/classes/class.debug.php +2 -2
  31. shared/classes/class.feedback.php +8 -8
  32. shared/classes/class.form.php +39 -286
  33. shared/classes/class.lead-fields.php +87 -55
  34. shared/classes/class.load-shared.php +50 -39
  35. shared/classes/class.post-type.email-template.php +2 -2
  36. shared/classes/class.shortcodes.email-template.php +1 -1
  37. shared/docs/analytics.events.md +352 -0
  38. shared/docs/css/blur.jpg +0 -0
  39. shared/docs/css/style.css +885 -0
  40. shared/docs/css/theme.css +84 -0
  41. shared/docs/index.html +94 -0
  42. shared/docs/js/flatdoc.js +515 -0
  43. shared/docs/js/jquery.js +5 -0
  44. shared/docs/js/legacy.js +369 -0
  45. shared/docs/js/script.js +250 -0
  46. shared/docs/js/theme.js +33 -0
  47. shared/docs/main.md +1029 -0
  48. shared/shortcodes/css/frontend-render.css +5 -1
  49. shared/shortcodes/js/tinymce.js +3 -3
  50. shared/shortcodes/shortcodes-includes.php +0 -9
  51. shared/tracking/new.store.lead.php +644 -0
  52. shared/tracking/page-tracking.js +1 -1
  53. shared/tracking/sources/Snowplow/RefererParser/Config/INBOUND_ConfigFileReaderTrait.php +54 -0
  54. shared/tracking/sources/Snowplow/RefererParser/Config/INBOUND_ConfigReaderInterface.php +15 -0
  55. shared/tracking/sources/Snowplow/RefererParser/Config/INBOUND_JsonConfigReader.php +57 -0
  56. shared/tracking/sources/Snowplow/RefererParser/Exception/INBOUND_InvalidArgumentException.php +9 -0
  57. shared/tracking/sources/Snowplow/RefererParser/INBOUND_Medium.php +16 -0
  58. shared/tracking/sources/Snowplow/RefererParser/INBOUND_Parser.php +266 -0
  59. shared/tracking/sources/Snowplow/RefererParser/INBOUND_Referer.php +78 -0
  60. shared/tracking/sources/referers.json +3890 -0
  61. shared/tracking/store.lead.php +7 -7
  62. templates/svtle/index.php +7 -6
  63. templates/tubelar/index.php +8 -0
js/jquery.form-population.js CHANGED
@@ -1 +1 @@
1
- function wpl_remember_inputs( selector ){
2
jQuery(selector).each(
3
function(){
4
//if this item has been cookied, restore it
5
var name = ( jQuery(this).attr('name') ) ? jQuery(this).attr('name') : '';
6
if( jQuery.cookie( name ) && type_input != 'submit' && type_input != 'hidden' && type_input != 'file' && name != 'comment' ){
7
jQuery(this).val( jQuery.cookie(name) );
8
}
9
//assign a change function to the item to cookie it
10
jQuery(this).change(
11
function(){
12
jQuery.cookie(name, jQuery(this).val(), { path: '/', expires: 365 });
13
}
14
);
15
}
16
);
17
jQuery(selector).each(
18
function(){
19
var form_name = jQuery(this).attr('name');
20
var form_id = jQuery(this).attr('id');
21
var form_class = jQuery(this).attr('class');
22
if(typeof(form_name) != "undefined" && form_name !== null) {
23
jQuery.cookie("lp_form_uid", form_name, { path: '/', expires: 365 });
24
}
25
else if(typeof(form_id) != "undefined" && form_id !== null) {
26
jQuery.cookie("lp_form_uid", form_id, { path: '/', expires: 365 });
27
}
28
else if (typeof(form_class) != "undefined" && form_class !== null) {
29
jQuery.cookie("lp_form_uid", form_class, { path: '/', expires: 365 });
30
} else {
31
jQuery.cookie("lp_form_uid", 'form_generic', { path: '/', expires: 365 });
32
}
33
}
34
);
35
// Fill Form Inputs from Cookies
36
});
37
<input type="text" name="name" />
38
<input type="email" name="email" />
39
<input type="text" name="address[addr1]" />
40
<input type="text" name="address[city]" />
41
<input type="text" name="address[state]" />
42
"email": "john@doe.com",
43
"name": "John Doe",
44
"address": {
45
"addr1": "Street name",
46
"city": "City name",
47
"state": "State"
48
}
49
for(var key in data) {
50
var name = key;
51
var value = data[key];
52
// no need to set empty values
53
if(value == "") {
54
continue;
55
}
56
// handle array name attributes
57
if(typeof(basename) !== "undefined") {
58
name = basename + "[" + key + "]";
59
}
60
if(value.constructor == Array) {
61
name += '[]';
62
} else if(typeof value == "object") {
63
populateFields(container, value, name);
64
continue;
65
}
66
// populate field
67
var elements = container.querySelectorAll('input[name="'+ name +'"], select[name="'+ name +'"], textarea[name="'+ name +'"]');
68
// Dirty: abandon if we did not find the element
69
if(!elements) {
70
return;
71
}
72
// loop through found elements to set their values
73
for(var i = 0; i < elements.length; i++) {
74
var element = elements[i];
75
// check element type
76
switch(element.type || element.tagName) {
77
case 'text':
78
case 'email':
79
case 'date':
80
case 'tel':
81
element.value = value;
82
break;
83
case 'radio':
84
element.checked = (element.value === value);
85
break;
86
case 'checkbox':
87
for(var j = 0; j < value.length; j++) {
88
element.checked = (element.value === value[j]);
89
}
90
break;
91
case 'select-multiple':
92
var values = value.constructor == Array ? value : [value];
93
for(var k = 0; k < element.options.length; k++)
94
{
95
for(var l = 0; l < values.length; l++)
96
{
97
element.options[k].selected |= (element.options[k].value == values[l]);
98
}
99
}
100
break;
101
case 'select':
102
case 'select-one':
103
element.value = value.toString() || value;
104
break;
105
}
106
}
107
}
108
var name = ( elements[i].name ) ? elements[i].name : '';
1
jQuery(selector).each(
2
function(){
3
//if this item has been cookied, restore it
4
var name = ( jQuery(this).attr('name') ) ? jQuery(this).attr('name') : '';
5
if( jQuery.cookie( name ) && type_input != 'submit' && type_input != 'hidden' && type_input != 'file' && name != 'comment' ){
6
jQuery(this).val( jQuery.cookie(name) );
7
}
8
//assign a change function to the item to cookie it
9
jQuery(this).change(
10
function(){
11
jQuery.cookie(name, jQuery(this).val(), { path: '/', expires: 365 });
12
}
13
);
14
}
15
);
16
jQuery(selector).each(
17
function(){
18
var form_name = jQuery(this).attr('name');
19
var form_id = jQuery(this).attr('id');
20
var form_class = jQuery(this).attr('class');
21
if(typeof(form_name) != "undefined" && form_name !== null) {
22
jQuery.cookie("lp_form_uid", form_name, { path: '/', expires: 365 });
23
}
24
else if(typeof(form_id) != "undefined" && form_id !== null) {
25
jQuery.cookie("lp_form_uid", form_id, { path: '/', expires: 365 });
26
}
27
else if (typeof(form_class) != "undefined" && form_class !== null) {
28
jQuery.cookie("lp_form_uid", form_class, { path: '/', expires: 365 });
29
} else {
30
jQuery.cookie("lp_form_uid", 'form_generic', { path: '/', expires: 365 });
31
}
32
}
33
);
34
// Fill Form Inputs from Cookies
35
});
36
+ /*
37
<input type="text" name="name" />
38
<input type="email" name="email" />
39
<input type="text" name="address[addr1]" />
40
<input type="text" name="address[city]" />
41
<input type="text" name="address[state]" />
42
"email": "john@doe.com",
43
"name": "John Doe",
44
"address": {
45
"addr1": "Street name",
46
"city": "City name",
47
"state": "State"
48
}
49
for(var key in data) {
50
var name = key;
51
var value = data[key];
52
// no need to set empty values
53
if(value == "") {
54
continue;
55
}
56
// handle array name attributes
57
if(typeof(basename) !== "undefined") {
58
name = basename + "[" + key + "]";
59
}
60
if(value.constructor == Array) {
61
name += '[]';
62
} else if(typeof value == "object") {
63
populateFields(container, value, name);
64
continue;
65
}
66
// populate field
67
var elements = container.querySelectorAll('input[name="'+ name +'"], select[name="'+ name +'"], textarea[name="'+ name +'"]');
68
// Dirty: abandon if we did not find the element
69
if(!elements) {
70
return;
71
}
72
// loop through found elements to set their values
73
for(var i = 0; i < elements.length; i++) {
74
var element = elements[i];
75
// check element type
76
switch(element.type || element.tagName) {
77
case 'text':
78
case 'email':
79
case 'date':
80
case 'tel':
81
element.value = value;
82
break;
83
case 'radio':
84
element.checked = (element.value === value);
85
break;
86
case 'checkbox':
87
for(var j = 0; j < value.length; j++) {
88
element.checked = (element.value === value[j]);
89
}
90
break;
91
case 'select-multiple':
92
var values = value.constructor == Array ? value : [value];
93
for(var k = 0; k < element.options.length; k++)
94
{
95
for(var l = 0; l < values.length; l++)
96
{
97
element.options[k].selected |= (element.options[k].value == values[l]);
98
}
99
}
100
break;
101
case 'select':
102
case 'select-one':
103
element.value = value.toString() || value;
104
break;
105
}
106
}
107
}
108
var name = ( elements[i].name ) ? elements[i].name : '';
js/page_view_track.js CHANGED
@@ -1,8 +1,11 @@
1
jQuery(document).ready(function($) {
2
3
- jQuery('form').each(function(){
4
- jQuery(this).addClass('wpl-track-me');
5
- });
6
7
// Saves variation page views
8
1
jQuery(document).ready(function($) {
2
3
+ setTimeout(function() {
4
+ jQuery('form').each(function(){
5
+ //jQuery(this).addClass('inbound-track');
6
+ });
7
+ }, 700);
8
+
9
10
// Saves variation page views
11
landing-pages.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Landing Pages
4
Plugin URI: http://www.inboundnow.com/landing-pages/
5
Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
6
- Version: 1.7.2
7
Author: Inbound Now
8
Author URI: http://www.inboundnow.com/
9
Text Domain: landing-pages
@@ -102,7 +102,7 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
102
*/
103
private static function load_constants() {
104
105
- define('LANDINGPAGES_CURRENT_VERSION', '1.7.2' );
106
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
107
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
108
define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
3
Plugin Name: Landing Pages
4
Plugin URI: http://www.inboundnow.com/landing-pages/
5
Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
6
+ Version: 1.7.3
7
Author: Inbound Now
8
Author URI: http://www.inboundnow.com/
9
Text Domain: landing-pages
102
*/
103
private static function load_constants() {
104
105
+ define('LANDINGPAGES_CURRENT_VERSION', '1.7.3' );
106
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
107
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
108
define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
modules/module.ab-testing.php CHANGED
@@ -74,15 +74,15 @@ if (is_admin())
74
{
75
$array_variations = explode(',',$variations);
76
$array_variations = lp_ab_unset_variation($array_variations,$_GET['lp-variation-id']);
77
-
78
/* set next variation to be open */
79
- $current_variation_id = current($array_variations);
80
$_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
81
-
82
$variations = implode(',' , $array_variations);
83
update_post_meta($post->ID,'lp-ab-variations', $variations);
84
-
85
-
86
if (isset($_GET['lp-variation-id']) && $_GET['lp-variation-id'] > 0 ) {
87
$suffix = '-'.$_GET['lp-variation-id'];
88
$len = strlen($suffix);
@@ -90,7 +90,7 @@ if (is_admin())
90
$suffix = '';
91
$len = strlen($suffix);
92
}
93
-
94
//delete each meta value associated with variation
95
global $wpdb;
96
$data = array();
@@ -111,7 +111,7 @@ if (is_admin())
111
delete_post_meta($_GET['post'], $key, $value);
112
}
113
}
114
-
115
$_GET['lp-variation-id'] = $current_variation_id;
116
}
117
@@ -346,14 +346,14 @@ if (is_admin())
346
foreach ($lp_custom_fields as $key=>$field)
347
{
348
$default = get_post_meta($post_id, $field['id'], true);
349
-
350
$id = $field['id'];
351
$field['id'] = $id.'-'.$current_variation_id ;
352
-
353
if ($default) {
354
$field['default'] = $default;
355
}
356
-
357
$lp_custom_fields[$key] = $field;
358
}
359
return $lp_custom_fields;
@@ -767,9 +767,11 @@ function lp_ab_testing_add_rewrite_rules()
767
768
$slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
769
//echo $slug;exit;
770
add_rewrite_rule("$slug/([^/]*)?", $this_path."modules/module.redirect-ab-testing.php?permalink_name=$1 ",'top');
771
add_rewrite_rule("landing-page=([^/]*)?", $this_path.'modules/module.redirect-ab-testing.php?permalink_name=$1','top');
772
-
773
add_filter('mod_rewrite_rules', 'lp_ab_testing_modify_rules', 1);
774
function lp_ab_testing_modify_rules($rules)
775
{
@@ -885,7 +887,7 @@ function lp_ab_testing_prepare_variation_callback()
885
die();
886
}
887
888
-
889
}
890
891
@@ -898,7 +900,7 @@ function lp_ab_testing_alter_content_area($content)
898
if ( !isset($post) || $post->post_type != 'landing-page' ) {
899
return $content;
900
}
901
-
902
$variation_id = lp_ab_testing_get_current_variation_id();
903
904
if ($variation_id>0)
@@ -932,14 +934,14 @@ function lp_ab_testing_record_impression($post_id, $post_type = 'landing-page' ,
932
/* If Landing Page Post Type */
933
if ( $post_type == 'landing-page' ) {
934
$meta_key = 'lp-ab-variation-impressions-'.$variation_id;
935
- }
936
/* If Non Landing Page Post Type */
937
else {
938
$meta_key = '_inbound_impressions_count';
939
}
940
-
941
$impressions = get_post_meta($post_id, $meta_key , true);
942
-
943
if (!is_numeric($impressions)) {
944
$impressions = 1;
945
} else {
74
{
75
$array_variations = explode(',',$variations);
76
$array_variations = lp_ab_unset_variation($array_variations,$_GET['lp-variation-id']);
77
+
78
/* set next variation to be open */
79
+ $current_variation_id = current($array_variations);
80
$_SESSION['lp_ab_test_open_variation'] = $current_variation_id;
81
+
82
$variations = implode(',' , $array_variations);
83
update_post_meta($post->ID,'lp-ab-variations', $variations);
84
+
85
+
86
if (isset($_GET['lp-variation-id']) && $_GET['lp-variation-id'] > 0 ) {
87
$suffix = '-'.$_GET['lp-variation-id'];
88
$len = strlen($suffix);
90
$suffix = '';
91
$len = strlen($suffix);
92
}
93
+
94
//delete each meta value associated with variation
95
global $wpdb;
96
$data = array();
111
delete_post_meta($_GET['post'], $key, $value);
112
}
113
}
114
+
115
$_GET['lp-variation-id'] = $current_variation_id;
116
}
117
346
foreach ($lp_custom_fields as $key=>$field)
347
{
348
$default = get_post_meta($post_id, $field['id'], true);
349
+
350
$id = $field['id'];
351
$field['id'] = $id.'-'.$current_variation_id ;
352
+
353
if ($default) {
354
$field['default'] = $default;
355
}
356
+
357
$lp_custom_fields[$key] = $field;
358
}
359
return $lp_custom_fields;
767
768
$slug = get_option( 'lp-main-landing-page-permalink-prefix', 'go' );
769
//echo $slug;exit;
770
+ $ab_testing = get_option( 'lp-main-landing-page-disable-turn-off-ab', "0");
771
+ if($ab_testing === "0") {
772
add_rewrite_rule("$slug/([^/]*)?", $this_path."modules/module.redirect-ab-testing.php?permalink_name=$1 ",'top');
773
add_rewrite_rule("landing-page=([^/]*)?", $this_path.'modules/module.redirect-ab-testing.php?permalink_name=$1','top');
774
+ }
775
add_filter('mod_rewrite_rules', 'lp_ab_testing_modify_rules', 1);
776
function lp_ab_testing_modify_rules($rules)
777
{
887
die();
888
}
889
890
+
891
}
892
893
900
if ( !isset($post) || $post->post_type != 'landing-page' ) {
901
return $content;
902
}
903
+
904
$variation_id = lp_ab_testing_get_current_variation_id();
905
906
if ($variation_id>0)
934
/* If Landing Page Post Type */
935
if ( $post_type == 'landing-page' ) {
936
$meta_key = 'lp-ab-variation-impressions-'.$variation_id;
937
+ }
938
/* If Non Landing Page Post Type */
939
else {
940
$meta_key = '_inbound_impressions_count';
941
}
942
+
943
$impressions = get_post_meta($post_id, $meta_key , true);
944
+
945
if (!is_numeric($impressions)) {
946
$impressions = 1;
947
} else {
modules/module.clone.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
modules/module.global-settings.php CHANGED
@@ -84,6 +84,14 @@ function lp_get_global_settings() {
84
'default' => '0',
85
'options' => array('1'=>'On','0'=>'Off')
86
),
87
);
88
89
@@ -122,10 +130,8 @@ function lp_get_global_settings() {
122
123
/* Add Extensions License Key Header if Extensions are present */
124
add_filter('lp_define_global_settings', 'lp_add_extension_license_key_header', 2, 1);
125
- function lp_add_extension_license_key_header($lp_global_settings)
126
- {
127
- if (array_key_exists('lp-license-keys',$lp_global_settings))
128
- {
129
$lp_global_settings['lp-license-keys']['settings'][] = array(
130
'id' => 'extensions-license-keys-header',
131
'description' => __( "Head to http://www.inboundnow.com/ to retrieve your license key for this template." , 'landing-pages'),
84
'default' => '0',
85
'options' => array('1'=>'On','0'=>'Off')
86
),
87
+ array(
88
+ 'id' => 'landing-page-disable-turn-off-ab',
89
+ 'label' => __('Turn Off AB Testing?' , 'landing-pages') ,
90
+ 'description' => __("This will disable the AB testing functionality of your landing pages. This is to comply with Googles new PPC regulations with redirects. After saving this option <a href='/wp-admin/options-permalink.php'>visit this page to flush/reset your permalinks</a>" , 'landing-pages'),
91
+ 'type' => 'radio',
92
+ 'default' => '0',
93
+ 'options' => array('0'=>'No Keep it on','1'=>'Yes turn AB testing Off')
94
+ )
95
);
96
97
130
131
/* Add Extensions License Key Header if Extensions are present */
132
add_filter('lp_define_global_settings', 'lp_add_extension_license_key_header', 2, 1);
133
+ function lp_add_extension_license_key_header($lp_global_settings) {
134
+ if (array_key_exists('lp-license-keys',$lp_global_settings)) {
135
$lp_global_settings['lp-license-keys']['settings'][] = array(
136
'id' => 'extensions-license-keys-header',
137
'description' => __( "Head to http://www.inboundnow.com/ to retrieve your license key for this template." , 'landing-pages'),
modules/module.install.php CHANGED
@@ -1,6 +1,6 @@
1
<?php
2
// Added Demo Landing on Install
3
- add_action('init', 'inbound_create_default_post_type');
4
function inbound_create_default_post_type(){
5
// NEED to insert custom meta as well
6
1
<?php
2
// Added Demo Landing on Install
3
+ add_action('admin_init', 'inbound_create_default_post_type');
4
function inbound_create_default_post_type(){
5
// NEED to insert custom meta as well
6
modules/module.javascript-frontend.php CHANGED
@@ -35,8 +35,7 @@ function lp_fontend_enqueue_scripts($hook) {
35
$form_prepopulation = get_option( 'lp-main-landing-page-prepopulate-forms' , 1);
36
// load form pre-population script
37
if ($form_prepopulation) {
38
- wp_register_script('form-population',LANDINGPAGES_URLPATH . 'js/jquery.form-population.js', array( 'jquery', 'jquery-cookie' ));
39
- wp_enqueue_script('form-population');
40
}
41
42
if (isset($_GET['template-customize']) &&$_GET['template-customize']=='on') {
35
$form_prepopulation = get_option( 'lp-main-landing-page-prepopulate-forms' , 1);
36
// load form pre-population script
37
if ($form_prepopulation) {
38
+ /* TODO set global option */
39
}
40
41
if (isset($_GET['template-customize']) &&$_GET['template-customize']=='on') {
modules/module.metaboxes-global.php CHANGED
@@ -20,6 +20,7 @@ function lp_add_global_meta_box( $post_type )
20
$exclude[] = 'inbound-email';
21
$exclude[] = 'inbound-log';
22
$exclude[] = 'landing-page';
23
// add filter
24
25
if ( $pagenow === 'post.php' && !in_array($post_type,$exclude) ) {
20
$exclude[] = 'inbound-email';
21
$exclude[] = 'inbound-log';
22
$exclude[] = 'landing-page';
23
+ $exclude[] = 'acf-field-group';
24
// add filter
25
26
if ( $pagenow === 'post.php' && !in_array($post_type,$exclude) ) {
modules/module.redirect-ab-testing.php CHANGED
@@ -18,6 +18,7 @@ class LP_Variation_Rotation {
18
19
static $permalink_name;
20
static $post_id;
21
static $last_loaded_variation;
22
static $variations;
23
static $marker;
@@ -42,11 +43,18 @@ class LP_Variation_Rotation {
42
{
43
self::$permalink_name = (isset($_GET['permalink_name'])) ? sanitize_text_field($_GET['permalink_name']) : null;
44
self::$post_id = self::load_post_id();
45
self::$last_loaded_variation = ( isset( $_COOKIE['lp-loaded-variation-'.self::$permalink_name] ) ) ? $_COOKIE['lp-loaded-variation-'.self::$permalink_name] : null;
46
- self::$variations = self::load_variations();
47
- self::$marker = self::load_marker();
48
- self::$next_marker = self::discover_next_variation();
49
- self::$destination_url = self::build_destination_url();
50
}
51
52
/**
18
19
static $permalink_name;
20
static $post_id;
21
+ static $sticky_variations;
22
static $last_loaded_variation;
23
static $variations;
24
static $marker;
43
{
44
self::$permalink_name = (isset($_GET['permalink_name'])) ? sanitize_text_field($_GET['permalink_name']) : null;
45
self::$post_id = self::load_post_id();
46
+ self::$sticky_variations = get_option( 'lp-main-landing-page-rotation-halt' , false );
47
self::$last_loaded_variation = ( isset( $_COOKIE['lp-loaded-variation-'.self::$permalink_name] ) ) ? $_COOKIE['lp-loaded-variation-'.self::$permalink_name] : null;
48
+
49
+ if ( self::$sticky_variations && self::$last_loaded_variation ) {
50
+ self::$destination_url = self::$last_loaded_variation;
51
+ } else {
52
+ self::$variations = self::load_variations();
53
+ self::$marker = self::load_marker();
54
+ self::$next_marker = self::discover_next_variation();
55
+ self::$destination_url = self::build_destination_url();
56
+ }
57
+
58
}
59
60
/**
modules/module.store.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
modules/module.templates.php CHANGED
@@ -32,24 +32,28 @@ else if (isset($_GET['page'])&&$_GET['page']=='lp_manage_templates')
32
private $singular;
33
private $plural;
34
35
- function __construct()
36
- {
37
$lp_data = lp_get_extension_data();
38
$final_data = array();
39
-
40
foreach ($lp_data as $key=>$data)
41
{
42
$array_core_templates = array('countdown-lander','default','demo','dropcap','half-and-half','simple-two-column','super-slick','svtle','tubelar','rsvp-envelope', 'simple-solid-lite', 'three-column-lander');
43
44
- if ($key == 'lp' || substr($key,0,4) == 'ext-' )
45
continue;
46
47
- if (isset($data['info']['data_type']) && $data['info']['data_type']=='metabox')
48
- continue;
49
50
- if (in_array($key,$array_core_templates))
51
continue;
52
53
//if (stristr($data['category'],'Theme Integrated'))
54
//continue;
55
@@ -60,12 +64,13 @@ else if (isset($_GET['page'])&&$_GET['page']=='lp_manage_templates')
60
}
61
}
62
63
- if (isset($data['thumbnail']))
64
$thumbnail = $data['thumbnail'];
65
- else if ($key=='default')
66
$thumbnail = get_bloginfo('template_directory')."/screenshot.png";
67
- else
68
$thumbnail = LANDINGPAGES_UPLOADS_URLPATH.$key."/thumbnail.png";
69
70
$this_data['ID'] = $key;
71
$this_data['template'] = $key;
@@ -75,12 +80,9 @@ else if (isset($_GET['page'])&&$_GET['page']=='lp_manage_templates')
75
( array_key_exists('info',$data) ) ? $this_data['description'] = $data['info']['description'] : $this_data['description'] = $data['description'];
76
77
$this_data['thumbnail'] = $thumbnail;
78
- if (isset($data['info']['version'])&&!empty($data['info']['version']))
79
- {
80
$this_data['version'] = $data['info']['version'];
81
- }
82
- else
83
- {
84
$this_data['version'] = "1.0.1";
85
}
86
@@ -102,8 +104,7 @@ else if (isset($_GET['page'])&&$_GET['page']=='lp_manage_templates')
102
$this->_args = $args;
103
}
104
105
- function get_columns()
106
- {
107
$columns = array(
108
'cb' => '<input type="checkbox" />',
109
'template' => __( 'Template' , 'landing-pages'),
32
private $singular;
33
private $plural;
34
35
+ function __construct() {
36
+
37
$lp_data = lp_get_extension_data();
38
$final_data = array();
39
+
40
foreach ($lp_data as $key=>$data)
41
{
42
$array_core_templates = array('countdown-lander','default','demo','dropcap','half-and-half','simple-two-column','super-slick','svtle','tubelar','rsvp-envelope', 'simple-solid-lite', 'three-column-lander');
43
44
+ if ($key == 'lp' || substr($key,0,4) == 'ext-' ) {
45
continue;
46
+ }
47
48
49
+ if (isset($data['info']['data_type']) && $data['info']['data_type']=='metabox') {
50
continue;
51
+ }
52
53
+
54
+ if (in_array($key,$array_core_templates)) {
55
+ continue;
56
+ }
57
//if (stristr($data['category'],'Theme Integrated'))
58
//continue;
59
64
}
65
}
66
67
+ if (isset($data['thumbnail'])) {
68
$thumbnail = $data['thumbnail'];
69
+ } else if ($key=='default') {
70
$thumbnail = get_bloginfo('template_directory')."/screenshot.png";
71
+ } else {
72
$thumbnail = LANDINGPAGES_UPLOADS_URLPATH.$key."/thumbnail.png";
73
+ }
74
75
$this_data['ID'] = $key;
76
$this_data['template'] = $key;
80
( array_key_exists('info',$data) ) ? $this_data['description'] = $data['info']['description'] : $this_data['description'] = $data['description'];
81
82
$this_data['thumbnail'] = $thumbnail;
83
+ if (isset($data['info']['version'])&&!empty($data['info']['version'])) {
84
$this_data['version'] = $data['info']['version'];
85
+ } else {
86
$this_data['version'] = "1.0.1";
87
}
88
104
$this->_args = $args;
105
}
106
107
+ function get_columns() {
108
$columns = array(
109
'cb' => '<input type="checkbox" />',
110
'template' => __( 'Template' , 'landing-pages'),
modules/module.track.php CHANGED
@@ -1 +1 @@
1
- <?php
2
$count_key = 'lp_page_views_count';
3
$count = get_post_meta($postID, $count_key, true);
4
if($count==''){
5
$count = 0;
6
delete_post_meta($postID, $count_key);
7
add_post_meta($postID, $count_key, '0');
8
}else{
9
$count++;
10
update_post_meta($postID, $count_key, $count);
11
}
12
$count_key = 'lp_page_conversions_count';
13
$count = get_post_meta($postID, $count_key, true);
14
if($count==''){
15
delete_post_meta($postID, $count_key);
16
add_post_meta($postID, $count_key, '0');
17
return "0";
18
}
19
return $count;
20
$count_key = 'lp_page_conversions_count';
21
$count = get_post_meta($postID, $count_key, true);
22
if($count==''){
23
$count = 0;
24
delete_post_meta($postID, $count_key);
25
add_post_meta($postID, $count_key, '0');
26
}else{
27
$count++;
28
update_post_meta($postID, $count_key, $count);
29
}
30
$count_key = 'lp_page_views_count';
31
$count = get_post_meta($postID, $count_key, true);
32
if($count==''){
33
delete_post_meta($postID, $count_key);
34
add_post_meta($postID, $count_key, '0');
35
return;
36
}
37
return $count;
38
$count_key = 'lp_page_views_count';
39
$count = get_post_meta($postID, $count_key, true);
40
if($count==''){
41
$count = 0;
42
delete_post_meta($postID, $count_key);
43
add_post_meta($postID, $count_key, '0');
44
}else{
45
$count++;
46
update_post_meta($postID, $count_key, $count);
47
}
48
$count_key = 'lp_page_conversions_count';
49
$count = get_post_meta($postID, $count_key, true);
50
if($count==''){
51
delete_post_meta($postID, $count_key);
52
add_post_meta($postID, $count_key, '0');
53
return "0";
54
}
55
return $count;
56
$count_key = 'lp_page_conversions_count';
57
$count = get_post_meta($postID, $count_key, true);
58
if($count==''){
59
$count = 0;
60
delete_post_meta($postID, $count_key);
61
add_post_meta($postID, $count_key, '0');
62
}else{
63
$count++;
64
update_post_meta($postID, $count_key, $count);
65
}
66
$count_key = 'lp_page_views_count';
67
$count = get_post_meta($postID, $count_key, true);
68
if($count==''){
69
delete_post_meta($postID, $count_key);
70
add_post_meta($postID, $count_key, '0');
71
return;
72
}
73
return $count;
1
$count_key = 'lp_page_views_count';
2
$count = get_post_meta($postID, $count_key, true);
3
if($count==''){
4
$count = 0;
5
delete_post_meta($postID, $count_key);
6
add_post_meta($postID, $count_key, '0');
7
}else{
8
$count++;
9
update_post_meta($postID, $count_key, $count);
10
}
11
$count_key = 'lp_page_conversions_count';
12
$count = get_post_meta($postID, $count_key, true);
13
if($count==''){
14
delete_post_meta($postID, $count_key);
15
add_post_meta($postID, $count_key, '0');
16
return "0";
17
}
18
return $count;
19
$count_key = 'lp_page_conversions_count';
20
$count = get_post_meta($postID, $count_key, true);
21
if($count==''){
22
$count = 0;
23
delete_post_meta($postID, $count_key);
24
add_post_meta($postID, $count_key, '0');
25
}else{
26
$count++;
27
update_post_meta($postID, $count_key, $count);
28
}
29
$count_key = 'lp_page_views_count';
30
$count = get_post_meta($postID, $count_key, true);
31
if($count==''){
32
delete_post_meta($postID, $count_key);
33
add_post_meta($postID, $count_key, '0');
34
return;
35
}
36
return $count;
37
+ <?php
38
$count_key = 'lp_page_views_count';
39
$count = get_post_meta($postID, $count_key, true);
40
if($count==''){
41
$count = 0;
42
delete_post_meta($postID, $count_key);
43
add_post_meta($postID, $count_key, '0');
44
}else{
45
$count++;
46
update_post_meta($postID, $count_key, $count);
47
}
48
$count_key = 'lp_page_conversions_count';
49
$count = get_post_meta($postID, $count_key, true);
50
if($count==''){
51
delete_post_meta($postID, $count_key);
52
add_post_meta($postID, $count_key, '0');
53
return "0";
54
}
55
return $count;
56
$count_key = 'lp_page_conversions_count';
57
$count = get_post_meta($postID, $count_key, true);
58
if($count==''){
59
$count = 0;
60
delete_post_meta($postID, $count_key);
61
add_post_meta($postID, $count_key, '0');
62
}else{
63
$count++;
64
update_post_meta($postID, $count_key, $count);
65
}
66
$count_key = 'lp_page_views_count';
67
$count = get_post_meta($postID, $count_key, true);
68
if($count==''){
69
delete_post_meta($postID, $count_key);
70
add_post_meta($postID, $count_key, '0');
71
return;
72
}
73
return $count;
readme.txt CHANGED
@@ -6,8 +6,8 @@ License: GPLv2 or later
6
License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
8
Requires at least: 3.8
9
- Tested up to: 3.9
10
- Stable Tag: 1.7.2
11
12
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
13
@@ -72,6 +72,9 @@ The plugin is also fully extendable and has a number of actions, filters, and ho
72
4. Choose from a ton of pre-made templates, use your existing design, or design your own theme!
73
74
== Changelog ==
75
= 1.7.2 =
76
* Improved form email typo detection
77
* Improved Template Styles
6
License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
8
Requires at least: 3.8
9
+ Tested up to: 4.0.1
10
+ Stable Tag: 1.7.3
11
12
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
13
72
4. Choose from a ton of pre-made templates, use your existing design, or design your own theme!
73
74
== Changelog ==
75
+ = 1.7.3 =
76
+ * See changelog here: https://github.com/inboundnow/landing-pages/issues?q=is%3Aissue+is%3Aclosed+label%3Av1.7.3
77
+
78
= 1.7.2 =
79
* Improved form email typo detection
80
* Improved Template Styles
shared/assets/assets.loader.class.php CHANGED
@@ -55,11 +55,14 @@ class Inbound_Asset_Loader {
55
wp_dequeue_script( $handle );
56
}
57
}
58
-
59
- self::load_file('funnel-tracking', 'frontend/js/page-tracking.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'wplft', self::localize_lead_data());
60
- //self::load_file('funnel-tracking', 'frontend/js/analytics/inboundAnalytics.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'wplft', self::localize_lead_data());
61
- // TODO: Merge Localize of wplft into inbound_ajax
62
self::load_file('store-lead-ajax', 'frontend/js/store.lead.ajax.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'inbound_ajax', self::localize_lead_data());
63
64
if (is_array($store)) {
65
foreach ( $store as $handle ) {
@@ -165,8 +168,21 @@ class Inbound_Asset_Loader {
165
$lead_data_array['lead_uid'] = ($lead_uid) ? $lead_uid : null;
166
$time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
167
$wordpress_date_time = date("Y/m/d G:i:s", $time);
168
-
169
- $inbound_localized_data = array( 'post_id' => $post_id, 'ip_address' => $ip_address, 'wp_lead_data' => $lead_data_array, 'admin_url' => admin_url( 'admin-ajax.php' ), 'track_time' => $wordpress_date_time, 'post_type' => $post_type, 'page_tracking' => $page_tracking, 'search_tracking' => $search_tracking, 'comment_tracking' => $comment_tracking, 'custom_mapping' => $custom_map_values);
170
171
return $inbound_localized_data;
172
} // end localize lead data
55
wp_dequeue_script( $handle );
56
}
57
}
58
+ /*if (!defined('InboundAnalytics_v2')) {
59
+ self::load_file('funnel-tracking', 'frontend/js/inbound.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'wplft', self::localize_lead_data());
60
self::load_file('store-lead-ajax', 'frontend/js/store.lead.ajax.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'inbound_ajax', self::localize_lead_data());
61
+ } else {
62
+ */
63
+
64
+ self::load_file('funnel-tracking', 'frontend/js/analytics/inboundAnalytics.js', array( 'jquery' ), 'inbound_settings', self::localize_lead_data());
65
+ /* } */
66
67
if (is_array($store)) {
68
foreach ( $store as $handle ) {
168
$lead_data_array['lead_uid'] = ($lead_uid) ? $lead_uid : null;
169
$time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
170
$wordpress_date_time = date("Y/m/d G:i:s", $time);
171
+ $inbound_track_include = get_option( 'wpl-main-tracking-ids');
172
+ $inbound_track_exclude = get_option( 'wpl-main-exclude-tracking-ids');
173
+ $inbound_localized_data = array('post_id' => $post_id,
174
+ 'ip_address' => $ip_address,
175
+ 'wp_lead_data' => $lead_data_array,
176
+ 'admin_url' => admin_url('admin-ajax.php'),
177
+ 'track_time' => $wordpress_date_time,
178
+ 'post_type' => $post_type,
179
+ 'page_tracking' => $page_tracking,
180
+ 'search_tracking' => $search_tracking,
181
+ 'comment_tracking' => $comment_tracking,
182
+ 'custom_mapping' => $custom_map_values,
183
+ 'inbound_track_exclude' => $inbound_track_exclude,
184
+ 'inbound_track_include' => $inbound_track_include
185
+ );
186
187
return $inbound_localized_data;
188
} // end localize lead data
shared/assets/frontend/js/analytics-src/analytics.events.js CHANGED
@@ -1,117 +1,519 @@
1
/**
2
- * Event functions
3
- * @param Object InboundAnalytics - Main JS object
4
- * @return Object - include event triggers
5
*/
6
- // https://github.com/carldanley/WP-JS-Hooks/blob/master/src/event-manager.js
7
- var InboundAnalyticsEvents = (function (InboundAnalytics) {
8
-
9
- InboundAnalytics.Events = {
10
- // Create cookie
11
- loadEvents: function() {
12
- this.analyticsLoaded();
13
- },
14
- triggerJQueryEvent: function(eventName, data){
15
if (window.jQuery) {
16
var data = data || {};
17
jQuery(document).trigger(eventName, data);
18
- /* var something = (function() {
19
- var executed = false;
20
- return function () {
21
- if (!executed) {
22
- executed = true;
23
- console.log(eventName + " RAN");
24
-
25
- }
26
- };
27
- })();*/
28
}
29
- },
30
- analyticsLoaded: function() {
31
- var eventName = "inbound_analytics_loaded";
32
- var loaded = new CustomEvent(eventName);
33
- window.dispatchEvent(loaded);
34
- this.triggerJQueryEvent(eventName);
35
- },
36
- analyticsTriggered: function() {
37
- var triggered = new CustomEvent("inbound_analytics_triggered");
38
- window.dispatchEvent(triggered);
39
- },
40
- analyticsSaved: function() {
41
- var page_view_saved = new CustomEvent("inbound_analytics_saved");
42
- window.dispatchEvent(page_view_saved);
43
- console.log('Page View Saved');
44
- },
45
- analyticsError: function(MLHttpRequest, textStatus, errorThrown) {
46
- var error = new CustomEvent("inbound_analytics_error", {
47
- detail: {
48
- MLHttpRequest: MLHttpRequest,
49
- textStatus: textStatus,
50
- errorThrown: errorThrown
51
- }
52
- });
53
- window.dispatchEvent(error);
54
- console.log('Page Save Error');
55
- },
56
- pageFirstView: function(page_seen_count) {
57
- var page_first_view = new CustomEvent("inbound_analytics_page_first_view", {
58
- detail: {
59
- count: 1,
60
- time: new Date(),
61
- },
62
- bubbles: true,
63
- cancelable: true
64
}
65
- );
66
- window.dispatchEvent(page_first_view);
67
-
68
- console.log('First Ever Page View of this Page');
69
- },
70
- pageRevisit: function(page_seen_count) {
71
- var eventName = "inbound_analytics_page_revisit";
72
- var data = { count: page_seen_count,
73
- time: new Date()
74
- };
75
- var page_revisit = new CustomEvent(eventName, {
76
- detail: data,
77
- bubbles: true,
78
- cancelable: true
79
}
80
- );
81
- window.dispatchEvent(page_revisit);
82
- this.triggerJQueryEvent(eventName, data);
83
- console.log('Page Revisit');
84
- },
85
- /* get idle times https://github.com/robflaherty/riveted/blob/master/riveted.js */
86
- browserTabHidden: function() {
87
- /* http://www.thefutureoftheweb.com/demo/2007-05-16-detect-browser-window-focus/ */
88
- var eventName = "inbound_analytics_tab_hidden";
89
- var tab_hidden = new CustomEvent(eventName);
90
- window.dispatchEvent(tab_hidden);
91
- console.log('Tab Hidden');
92
- this.triggerJQueryEvent(eventName);
93
- },
94
- browserTabVisible: function() {
95
- var eventName = "inbound_analytics_tab_visible";
96
- var tab_visible = new CustomEvent(eventName);
97
- window.dispatchEvent(tab_visible);
98
- console.log('Tab Visible');
99
- this.triggerJQueryEvent(eventName);
100
- },
101
- /* Scrol depth https://github.com/robflaherty/jquery-scrolldepth/blob/master/jquery.scrolldepth.js */
102
- sessionStart: function() {
103
- var session_start = new CustomEvent("inbound_analytics_session_start");
104
- window.dispatchEvent(session_start);
105
- console.log('Session Start');
106
- },
107
- sessionActive: function() {
108
- var session_active = new CustomEvent("inbound_analytics_session_active");
109
- window.dispatchEvent(session_active);
110
- console.log('Session Active');
111
- },
112
-
113
- };
114
-
115
- return InboundAnalytics;
116
-
117
- })(InboundAnalytics || {});
1
/**
2
+ * # Analytics Events
3
+ *
4
+ * Events are triggered throughout the visitors journey through the site. See more on [Inbound Now][in]
5
+ *
6
+ * @author David Wells <david@inboundnow.com>
7
+ * @version 0.0.1
8
+ *
9
+ * [in]: http://www.inboundnow.com/
10
*/
11
+
12
+ // Add object to _inbound
13
+ var _inboundEvents = (function(_inbound) {
14
+
15
+
16
+ _inbound.trigger = function(trigger, data) {
17
+ _inbound.Events[trigger](data);
18
+
19
+ };
20
+
21
+ /*!
22
+ *
23
+ * Private Function that Fires & Emits Events
24
+ *
25
+ * There are three options for firing events and they trigger in this order:
26
+ *
27
+ * 1. Vanilla JS dispatch event
28
+ * 2. `_inbound.add_action('namespace', callback, priority)`
29
+ * 3. jQuery Trigger `jQuery.trigger('namespace', callback);`
30
+ *
31
+ * The Event `data` can be filtered before events are triggered
32
+ * with filters. Example: filter_ + "namespace"
33
+ *
34
+ * ```js
35
+ * // Filter Form Data before submissionsz
36
+ * _inbound.add_filter( 'filter_form_before_submission', event_filter_data_example, 10);
37
+ *
38
+ * function event_filter_data_example(data) {
39
+ * var data = data || {};
40
+ * // Do something with data
41
+ * return data;
42
+ * }
43
+ * ```
44
+ *
45
+ * @param {string} eventName Name of the event
46
+ * @param {object} data Data passed to external functions/triggers
47
+ * @param {object} options Options for configuring events
48
+ * @return {null} Nothing returned
49
+ */
50
+ function fireEvent(eventName, data, options) {
51
+ var data = data || {};
52
+ options = options || {};
53
+ //alert('ran + ' + eventName);
54
+ //console.log(eventName);
55
+ //console.log(data);
56
+ /*! defaults for JS dispatch event */
57
+ options.bubbles = options.bubbles || true,
58
+ options.cancelable = options.cancelable || true;
59
+
60
+ /*! Customize Data via filter_ + "namespace" */
61
+ data = _inbound.apply_filters('filter_' + eventName, data);
62
+
63
+ var TriggerEvent = new CustomEvent(eventName, {
64
+ detail: data,
65
+ bubbles: options.bubbles,
66
+ cancelable: options.cancelable
67
+ });
68
+
69
+ // console.log('Action:' + eventName + " ran on ->", data);
70
+
71
+ /*! 1. Trigger Pure Javascript Event See: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events for example on creating events */
72
+ window.dispatchEvent(TriggerEvent);
73
+ /*! 2. Trigger _inbound action */
74
+ _inbound.do_action(eventName, data);
75
+ /*! 3. jQuery trigger */
76
+ triggerJQueryEvent(eventName, data);
77
+
78
+ }
79
+
80
+ function triggerJQueryEvent(eventName, data) {
81
if (window.jQuery) {
82
var data = data || {};
83
jQuery(document).trigger(eventName, data);
84
}
85
+ };
86
+
87
+ var universalGA,
88
+ classicGA,
89
+ googleTagManager;
90
+
91
+ _inbound.Events = {
92
+
93
+ /**
94
+ * # Event Usage
95
+ *
96
+ * Events are triggered throughout the visitors path through the site.
97
+ * You can hook into these custom actions and filters much like WordPress Core
98
+ *
99
+ * See below for examples
100
+ */
101
+
102
+ /**
103
+ * Adding Custom Actions
104
+ * ------------------
105
+ * You can hook into custom events throughout analytics. See the full list of available [events below](#all-events)
106
+ *
107
+ * `
108
+ * _inbound.add_action( 'action_name', callback, priority );
109
+ * `
110
+ *
111
+ * ```js
112
+ * // example:
113
+ *
114
+ * // Add custom function to `page_visit` event
115
+ * _inbound.add_action( 'page_visit', callback, 10 );
116
+ *
117
+ * // add custom callback to trigger when `page_visit` fires
118
+ * function callback(pageData){
119
+ * var pageData = pageData || {};
120
+ * // run callback on 'page_visit' trigger
121
+ * alert(pageData.title);
122
+ * }
123
+ * ```
124
+ *
125
+ * @param {string} action_name Name of the event trigger
126
+ * @param {function} callback function to trigger when event happens
127
+ * @param {int} priority Order to trigger the event in
128
+ *
129
+ */
130
+
131
+ /**
132
+ * Removing Custom Actions
133
+ * ------------------
134
+ * You can hook into custom events throughout analytics. See the full list of available [events below](#all-events)
135
+ *
136
+ * `
137
+ * _inbound.remove_action( 'action_name');
138
+ * `
139
+ *
140
+ * ```js
141
+ * // example:
142
+ *
143
+ * _inbound.remove_action( 'page_visit');
144
+ * // all 'page_visit' actions have been deregistered
145
+ * ```
146
+ *
147
+ * @param {string} action_name Name of the event trigger
148
+ *
149
+ */
150
+
151
+ /**
152
+ * # Event List
153
+ *
154
+ * Events are triggered throughout the visitors journey through the site
155
+ */
156
+
157
+ /**
158
+ * Triggers when analyics has finished loading
159
+ */
160
+ analytics_ready: function() {
161
+ var ops = {
162
+ 'opt1': true
163
+ };
164
+ var data = {
165
+ 'data': 'xyxy'
166
+ };
167
+ fireEvent('analytics_ready', data, ops);
168
+ },
169
+ /**
170
+ * Triggers when the browser url params are parsed. You can perform custom actions
171
+ * if specific url params exist.
172
+ *
173
+ * ```js
174
+ * // Usage:
175
+ *
176
+ * // Add function to 'url_parameters' event
177
+ * _inbound.add_action( 'url_parameters', url_parameters_func_example, 10);
178
+ *
179
+ * function url_parameters_func_example(urlParams) {
180
+ * var urlParams = urlParams || {};
181
+ * for( var param in urlParams ) {
182
+ * var key = param;
183
+ * var value = urlParams[param];
184
+ * }
185
+ * // All URL Params
186
+ * alert(JSON.stringify(urlParams));
187
+ *
188
+ * // Check if URL parameter `utm_source` exists and matches value
189
+ * if(urlParams.utm_source === "twitter") {
190
+ * alert('This person is from twitter!');
191
+ * }
192
+ * }
193
+ * ```
194
+ */
195
+ url_parameters: function(data) {
196
+ fireEvent('url_parameters', data);
197
+ },
198
+ /**
199
+ * Triggers when session starts
200
+ *
201
+ * ```js
202
+ * // Usage:
203
+ *
204
+ * // Add function to 'session_start' event
205
+ * _inbound.add_action( 'session_start', session_start_func_example, 10);
206
+ *
207
+ * function session_start_func_example(data) {
208
+ * var data = data || {};
209
+ * // session start. Do something for new visitor
210
+ * }
211
+ * ```
212
+ */
213
+ session_start: function() {
214
+ console.log('');
215
+ fireEvent('session_start');
216
+ },
217
+ /**
218
+ * Triggers when visitor session goes idle for more than 30 minutes.
219
+ *
220
+ * ```js
221
+ * // Usage:
222
+ *
223
+ * // Add function to 'session_end' event
224
+ * _inbound.add_action( 'session_end', session_end_func_example, 10);
225
+ *
226
+ * function session_end_func_example(data) {
227
+ * var data = data || {};
228
+ * // Do something when session ends
229
+ * alert("Hey! It's been 30 minutes... where did you go?");
230
+ * }
231
+ * ```
232
+ */
233
+ session_end: function(clockTime) {
234
+ fireEvent('session_end', clockTime);
235
+ console.log('Session End');
236
+ },
237
+ /**
238
+ * Triggers if active session is detected
239
+ *
240
+ * ```js
241
+ * // Usage:
242
+ *
243
+ * // Add function to 'session_active' event
244
+ * _inbound.add_action( 'session_active', session_active_func_example, 10);
245
+ *
246
+ * function session_active_func_example(data) {
247
+ * var data = data || {};
248
+ * // session active
249
+ * }
250
+ * ```
251
+ */
252
+ session_active: function() {
253
+ fireEvent('session_active');
254
+ },
255
+ /**
256
+ * Triggers when visitor session goes idle. Idling occurs after 60 seconds of
257
+ * inactivity or when the visitor switches browser tabs
258
+ *
259
+ * ```js
260
+ * // Usage:
261
+ *
262
+ * // Add function to 'session_idle' event
263
+ * _inbound.add_action( 'session_idle', session_idle_func_example, 10);
264
+ *
265
+ * function session_idle_func_example(data) {
266
+ * var data = data || {};
267
+ * // Do something when session idles
268
+ * alert('Here is a special offer for you!');
269
+ * }
270
+ * ```
271
+ */
272
+ session_idle: function(clockTime) {
273
+ fireEvent('session_idle', clockTime);
274
+ },
275
+ /**
276
+ * Triggers when session is already active and gets resumed
277
+ *
278
+ * ```js
279
+ * // Usage:
280
+ *
281
+ * // Add function to 'session_resume' event
282
+ * _inbound.add_action( 'session_resume', session_resume_func_example, 10);
283
+ *
284
+ * function session_resume_func_example(data) {
285
+ * var data = data || {};
286
+ * // Session exists and is being resumed
287
+ * }
288
+ * ```
289
+ */
290
+ session_resume: function() {
291
+ fireEvent('session_resume');
292
+ },
293
+ /**
294
+ * Session emitter. Runs every 10 seconds. This is a useful function for
295
+ * pinging third party services
296
+ *
297
+ * ```js
298
+ * // Usage:
299
+ *
300
+ * // Add session_heartbeat_func_example function to 'session_heartbeat' event
301
+ * _inbound.add_action( 'session_heartbeat', session_heartbeat_func_example, 10);
302
+ *
303
+ * function session_heartbeat_func_example(data) {
304
+ * var data = data || {};
305
+ * // Do something with every 10 seconds
306
+ * }
307
+ * ```
308
+ */
309
+ session_heartbeat: function(clockTime) {
310
+ var data = {
311
+ 'clock': clockTime,
312
+ 'leadData': InboundLeadData
313
+ };
314
+ fireEvent('session_heartbeat', data);
315
+ },
316
+ /**
317
+ * Triggers Every Page View
318
+ *
319
+ * ```js
320
+ * // Usage:
321
+ *
322
+ * // Add function to 'page_visit' event
323
+ * _inbound.add_action( 'page_visit', page_visit_func_example, 10);
324
+ *
325
+ * function session_idle_func_example(pageData) {
326
+ * var pageData = pageData || {};
327
+ * if( pageData.view_count > 8 ){
328
+ * alert('Wow you have been to this page more than 8 times.');
329
+ * }
330
+ * }
331
+ * ```
332
+ */
333
+ page_visit: function(pageData) {
334
+ fireEvent('page_view', pageData);
335
+ },
336
+ /**
337
+ * Triggers If the visitor has never seen the page before
338
+ *
339
+ * ```js
340
+ * // Usage:
341
+ *
342
+ * // Add function to 'page_first_visit' event
343
+ * _inbound.add_action( 'page_first_visit', page_first_visit_func_example, 10);
344
+ *
345
+ * function page_first_visit_func_example(pageData) {
346
+ * var pageData = pageData || {};
347
+ * alert('Welcome to this page! Its the first time you have seen it')
348
+ * }
349
+ * ```
350
+ */
351
+ page_first_visit: function(pageData) {
352
+ fireEvent('page_first_visit');
353
+ _inbound.deBugger('pages', 'First Ever Page View of this Page');
354
+ },
355
+ /**
356
+ * Triggers If the visitor has seen the page before
357
+ *
358
+ * ```js
359
+ * // Usage:
360
+ *
361
+ * // Add function to 'page_revisit' event
362
+ * _inbound.add_action( 'page_revisit', page_revisit_func_example, 10);
363
+ *
364
+ * function page_revisit_func_example(pageData) {
365
+ * var pageData = pageData || {};
366
+ * alert('Welcome back to this page!');
367
+ * // Show visitor special content/offer
368
+ * }
369
+ * ```
370
+ */
371
+ page_revisit: function(pageData) {
372
+
373
+ fireEvent('page_revisit', pageData);
374
+
375
+ var logger = function() {
376
+ console.log('pageData', pageData);
377
+ console.log('Page Revisit viewed ' + pageData + " times");
378
}
379
+ _inbound.deBugger('pages', status, logger);
380
+ },
381
+
382
+ /**
383
+ * `tab_hidden` is triggered when the visitor switches browser tabs
384
+ *
385
+ * ```js
386
+ * // Usage:
387
+ *
388
+ * // Adding the callback
389
+ * function tab_hidden_function( data ) {
390
+ * alert('The Tab is Hidden');
391
+ * };
392
+ *
393
+ * // Hook the function up the the `tab_hidden` event
394
+ * _inbound.add_action( 'tab_hidden', tab_hidden_function, 10 );
395
+ * ```
396
+ */
397
+ tab_hidden: function(data) {
398
+ _inbound.deBugger('pages', 'Tab Hidden');
399
+ fireEvent('tab_hidden');
400
+ },
401
+ /**
402
+ * `tab_visible` is triggered when the visitor switches back to the sites tab
403
+ *
404
+ * ```js
405
+ * // Usage:
406
+ *
407
+ * // Adding the callback
408
+ * function tab_visible_function( data ) {
409
+ * alert('Welcome back to this tab!');
410
+ * // trigger popup or offer special discount etc.
411
+ * };
412
+ *
413
+ * // Hook the function up the the `tab_visible` event
414
+ * _inbound.add_action( 'tab_visible', tab_visible_function, 10 );
415
+ * ```
416
+ */
417
+ tab_visible: function(data) {
418
+ _inbound.deBugger('pages', 'Tab Visible');
419
+ fireEvent('tab_visible');
420
+ },
421
+ /**
422
+ * `tab_mouseout` is triggered when the visitor mouses out of the browser window.
423
+ * This is especially useful for exit popups
424
+ *
425
+ * ```js
426
+ * // Usage:
427
+ *
428
+ * // Adding the callback
429
+ * function tab_mouseout_function( data ) {
430
+ * alert("Wait don't Go");
431
+ * // trigger popup or offer special discount etc.
432
+ * };
433
+ *
434
+ * // Hook the function up the the `tab_mouseout` event
435
+ * _inbound.add_action( 'tab_mouseout', tab_mouseout_function, 10 );
436
+ * ```
437
+ */
438
+ tab_mouseout: function(data) {
439
+ _inbound.deBugger('pages', 'Tab Mouseout');
440
+ fireEvent('tab_mouseout');
441
+ },
442
+ /**
443
+ * `form_input_change` is triggered when tracked form inputs change
444
+ * You can use this to add additional validation or set conditional triggers
445
+ *
446
+ * ```js
447
+ * // Usage:
448
+ *
449
+ * ```
450
+ */
451
+ form_input_change: function(inputData) {
452
+ var logger = function() {
453
+ console.log(inputData);
454
+ //console.log('Page Revisit viewed ' + pageData + " times");
455
}
456
+ _inbound.deBugger('forms', 'inputData change. Data=', logger);
457
+ fireEvent('form_input_change', inputData);
458
+ },
459
+ /**
460
+ * `form_before_submission` is triggered before the form is submitted to the server.
461
+ * You can filter the data here or send it to third party services
462
+ *
463
+ * ```js
464
+ * // Usage:
465
+ *
466
+ * // Adding the callback
467
+ * function form_before_submission_function( data ) {
468
+ * var data = data || {};
469
+ * // filter form data
470
+ * };
471
+ *
472
+ * // Hook the function up the the `form_before_submission` event
473
+ * _inbound.add_action( 'form_before_submission', form_before_submission_function, 10 );
474
+ * ```
475
+ */
476
+ form_before_submission: function(formData) {
477
+ fireEvent('form_before_submission', formData);
478
+ },
479
+ /**
480
+ * `form_after_submission` is triggered after the form is submitted to the server.
481
+ * You can filter the data here or send it to third party services
482
+ *
483
+ * ```js
484
+ * // Usage:
485
+ *
486
+ * // Adding the callback
487
+ * function form_after_submission_function( data ) {
488
+ * var data = data || {};
489
+ * // filter form data
490
+ * };
491
+ *
492
+ * // Hook the function up the the `form_after_submission` event
493
+ * _inbound.add_action( 'form_after_submission', form_after_submission_function, 10 );
494
+ * ```
495
+ */
496
+ form_after_submission: function(formData) {
497
+
498
+ fireEvent('form_after_submission', formData);
499
+
500
+ },
501
+ /*! Scrol depth https://github.com/robflaherty/jquery-scrolldepth/blob/master/jquery.scrolldepth.js */
502
+
503
+ analyticsError: function(MLHttpRequest, textStatus, errorThrown) {
504
+ var error = new CustomEvent("inbound_analytics_error", {
505
+ detail: {
506
+ MLHttpRequest: MLHttpRequest,
507
+ textStatus: textStatus,
508
+ errorThrown: errorThrown
509
+ }
510
+ });
511
+ window.dispatchEvent(error);
512
+ console.log('Page Save Error');
513
+ },
514
+
515
+ };
516
+
517
+ return _inbound;
518
+
519
+ })(_inbound || {});
shared/assets/frontend/js/analytics-src/analytics.examples.js ADDED
@@ -0,0 +1,185 @@
1
+ /*
2
+ URL param action
3
+ */
4
+ // Add to page
5
+ _inbound.add_action('url_parameters', URL_Param_Function, 10);
6
+ // callback function
7
+ function URL_Param_Function(urlParams) {
8
+
9
+ //urlParams = _inbound.apply_filters( 'urlParamFilter', urlParams);
10
+
11
+ for (var param in urlParams) {
12
+ var key = param;
13
+ var value = urlParams[param];
14
+ }
15
+
16
+ //alert(JSON.stringify(urlParams));
17
+
18
+ /* Check if URL parameter exists and matches value */
19
+ if (urlParams.test === "true") {
20
+ alert('url param true is true');
21
+ }
22
+ }
23
+
24
+ /* Applying filters to your actions */
25
+ _inbound.add_filter('filter_url_parameters', URL_Param_Filter, 10);
26
+
27
+ function URL_Param_Filter(urlParams) {
28
+
29
+ var params = urlParams || {};
30
+ /* check for item in object */
31
+ if (params.utm_source !== "undefined") {
32
+ //alert('its here');
33
+ }
34
+ /* delete item from object */
35
+ delete params.utm_source;
36
+
37
+ return params;
38
+
39
+ }
40
+
41
+ /* Applying filters to your actions */
42
+ _inbound.add_filter('filter_inbound_analytics_loaded', event_filter_data_example, 10);
43
+
44
+ function event_filter_data_example(data) {
45
+
46
+ var data = data || {};
47
+
48
+ /* Add property to data */
49
+ data.add_this = 'additional data';
50
+
51
+ /* check for item in object */
52
+ if (data.opt1 === true) {
53
+ alert('options.opt1 = true');
54
+ }
55
+
56
+ /* Add or modifiy option to event */
57
+ data.new_options = 'new option';
58
+
59
+ /* delete item from data */
60
+ delete data.utm_source;
61
+
62
+ return data;
63
+
64
+ }
65
+
66
+ _inbound.add_action('tab_hidden', Tab_Hidden_Function, 10);
67
+
68
+ function Tab_Hidden_Function(data) {
69
+ //alert('NOPE! LOOK AT ME!!!!');
70
+ }
71
+
72
+ _inbound.add_action('tab_visible', tab_visible_function, 9);
73
+
74
+ function tab_visible_function(data) {
75
+ //alert('Welcome back to the tab');
76
+ }
77
+
78
+ _inbound.add_action('tab_mouseout', tab_mouseout_function, 10);
79
+
80
+ function tab_mouseout_function(data) {
81
+ //alert('You moused out of the tab');
82
+ document.body.style.background = 'red';
83
+ }
84
+
85
+ _inbound.add_action('page_first_visit', Tab_vis_Function, 10);
86
+
87
+ function Tab_vis_Function(data) {
88
+ //alert('Welcome back bro 2');
89
+ }
90
+
91
+ _inbound.add_action('page_revisit', page_revisit_Function, 10);
92
+
93
+ function page_revisit_Function(data) {
94
+ console.log('Welcome page_revisit');
95
+ }
96
+
97
+ window.addEventListener("page_revisit", page_seen_function, false);
98
+
99
+ function page_seen_function(e) {
100
+ var view_count = e.detail.count;
101
+ console.log("This page has been seen " + e.detail.count + " times");
102
+ if (view_count > 10) {
103
+ console.log("Page has been viewed more than 10 times");
104
+ }
105
+ }
106
+
107
+ _inbound.add_action('session_start', session_start_func, 10);
108
+
109
+ function session_start_func(data) {
110
+ //alert('Session starting Now');
111
+ }
112
+
113
+ _inbound.add_action('session_resume', session_resume_func, 10);
114
+
115
+ function session_resume_func(data) {
116
+ //alert('Session Resume');
117
+ }
118
+
119
+
120
+
121
+ _inbound.add_action('session_init', session_end_func, 10);
122
+
123
+ function session_end_func(data) {
124
+ //alert('Session session_end');
125
+ }
126
+
127
+
128
+ _inbound.add_action('session_end', session_end_func, 10);
129
+
130
+ function session_end_func(data) {
131
+ //alert('Session session_end');
132
+ }
133
+
134
+ _inbound.add_action('analytics_ready', analytics_ready_func, 10);
135
+
136
+ function analytics_ready_func(data) {
137
+ //alert('analytics_ready');
138
+ }
139
+
140
+ _inbound.add_action('form_input_change', form_input_change_func, 10);
141
+
142
+ function form_input_change_func(inputData) {
143
+ var inputData = inputData || {};
144
+ console.log(inputData); // View input data object
145
+ console.log(inputData.node + '[name="' + inputData.name + '"]');
146
+ /*jQuery(inputData.node + '[name="'+inputData.name+'"]')
147
+ .animate({
148
+ opacity: 0.50,
149
+ left: "+=50",
150
+ }, 1000, function() {
151
+ jQuery(this).css('color', 'green');
152
+ });*/
153
+ }
154
+
155
+ _inbound.add_action('form_after_submission', form_after_submission_func, 10);
156
+
157
+ function form_after_submission_func(data) {
158
+ console.log('do this');
159
+ // alert(JSON.stringify(data));
160
+ }
161
+
162
+ /* Jquery Examples */
163
+
164
+ _inbound.add_action('form_before_submission', alert_form_data, 10);
165
+
166
+ function alert_form_data(data) {
167
+ console.log(JSON.stringify(data));
168
+ }
169
+ //_inbound.remove_action( 'inbound_form_form_before_submission');
170
+ /* raw_js_trigger event trigger */
171
+ window.addEventListener("form_before_submission", raw_js_trigger, false);
172
+
173
+ function raw_js_trigger(e) {
174
+ var data = e.detail;
175
+ console.log('Pure Javascript form_before_submission action fire');
176
+ //alert(JSON.stringify(data.raw_params));
177
+ }
178
+
179
+ if (window.jQuery) {
180
+ jQuery(document).on('form_before_submission', function(event, data) {
181
+
182
+ console.log('Run jQuery form_before_submission trigger');
183
+
184
+ });
185
+ }
shared/assets/frontend/js/analytics-src/analytics.forms.js CHANGED
@@ -1,141 +1,970 @@
1
/**
2
- * Form functions
3
- * @param Object InboundAnalytics - Form tracking functionality
4
- * @return Object - form functions
5
*/
6
- var InboundForms = (function (InboundAnalytics) {
7
-
8
- InboundAnalytics.Forms = {
9
- // Init Form functions
10
- init: function() {
11
- this.attachFormSubmitEvent();
12
- },
13
- formLoop: function(){
14
- for(var i=0; i<window.document.forms.length; i++){
15
- var form = window.document.forms[i];
16
- var trackForm = InboundAnalytics.Utils.hasClass("wpl-track-me", form);
17
- if (trackForm) {
18
- this.attachFormSubmitEvent(form); /* attach form listener */
19
-
20
- }
21
- }
22
- },
23
- formSubmit: function(form) {
24
-
25
- },
26
- mapFormValues: function(form) {
27
- var inputByName = {};
28
- var params = [];
29
- /* test for [] array syntax */
30
- var fieldNameExp = /\[([^\[]*)\]/g;
31
- for (var i=0; i < form.elements.length; i++) {
32
-
33
- formField = form.elements[i];
34
multiple = false;
35
36
- if (formField.name) {
37
- /* test for [] array syntax */
38
- cleanName = formField.name.replace(fieldNameExp, "_$1");
39
- if (!inputByName[cleanName]) { inputByName[cleanName] = []; }
40
41
- switch (formField.nodeName) {
42
43
case 'INPUT':
44
- value = this.getInputValue(formField);
45
- console.log(value);
46
- if (value === false) { continue; }
47
break;
48
49
case 'SELECT':
50
- if (formField.multiple) {
51
values = [];
52
multiple = true;
53
54
- for (var j = 0; j < formField.length; j++) {
55
- if (formField[j].selected) {
56
- values.push(encodeURIComponent(formField[j].value));
57
}
58
}
59
60
} else {
61
- value = (formField.value);
62
}
63
- break;
64
65
- case 'TEXTAREA':
66
- value = formField.value;
67
break;
68
-
69
}
70
71
if (value) {
72
- inputByName[cleanName].push(multiple ? values.join(',') : encodeURIComponent(value));
73
}
74
75
}
76
-
77
}
78
var matchCommon = /name|first name|last name|email|e-mail|phone|website|job title|company|tele|address|comment/;
79
- for (var inputName in inputByName) {
80
- if (matchCommon.test(inputName) !== false) {
81
- console.log(inputName + " Matches Regex");
82
- /* run mapping loop only for the matches here */
83
- }
84
- params.push( inputName + '=' + inputByName[inputName].join(',') );
85
- }
86
- var final_params = params.join('&');
87
- console.log(final_params);
88
- },
89
- getInputValue = function(input) {
90
- var value = false;
91
-
92
- switch (input.type) {
93
- case 'radio':
94
- case 'checkbox':
95
- if (input.checked) {
96
- value = input.value;
97
- }
98
- break;
99
-
100
- case 'text':
101
- case 'hidden':
102
- default:
103
- value = input.value;
104
- break;
105
-
106
- }
107
-
108
- return value;
109
-
110
- },
111
- /*
112
- inbound_form_classes: function(forms, functionName, classes) {
113
- jQuery.each(forms, function(index, id) {
114
- var selector = jQuery.trim(id);
115
- for (var this_class in classes) {
116
- if (selector.indexOf('#')>-1) {
117
- jQuery(selector)[functionName](classes[this_class]);
118
- //console.log(selector);
119
- } else if (selector.indexOf('.')>-1) {
120
- jQuery(selector)[functionName](classes[this_class]);
121
} else {
122
- jQuery("#" + selector)[functionName](classes[this_class]);
123
}
124
- }
125
126
- });
127
- }*/
128
- /* Add tracking class to forms */
129
- attachFormSubmitEvent: function (form) {
130
131
- console.log("The Form has the class wpl-track-me", hasClass);
132
- InboundAnalytics.Utils.addListener(form, 'submit', InboundAnalytics.LeadsAPI.formSubmit );
133
134
- },
135
136
137
- };
138
139
- return InboundAnalytics;
140
141
- })(InboundAnalytics || {});
1
/**
2
+ * # Inbound Forms
3
+ *
4
+ * This file contains all of the form functions of the main _inbound object.
5
+ * Filters and actions are described below
6
+ *
7
+ * @author David Wells <david@inboundnow.com>
8
+ * @version 0.0.1
9
*/
10
+ /* Finish Exclusions for CC */
11
+
12
+ /* Launches form class */
13
+ var InboundForms = (function(_inbound) {
14
+
15
+ var debugMode = false,
16
+ utils = _inbound.Utils,
17
+ no_match = [],
18
+ rawParams = [],
19
+ mappedParams = [],
20
+ settings = _inbound.Settings;
21
+
22
+ var FieldMapArray = [
23
+ "first name",
24
+ "last name",
25
+ "name",
26
+ "email",
27
+ "e-mail",
28
+ "phone",
29
+ "website",
30
+ "job title",
31
+ "your favorite food",
32
+ "company",
33
+ "tele",
34
+ "address",
35
+ "comment"
36
+ /* Adding values here maps them */
37
+ ];
38
+
39
+ _inbound.Forms = {
40
+
41
+ // Init Form functions
42
+ init: function() {
43
+ _inbound.Forms.runFieldMappingFilters();
44
+ _inbound.Forms.assignTrackClass();
45
+ _inbound.Forms.formTrackInit();
46
+ },
47
+ /**
48
+ * This triggers the forms.field_map filter on the mapping array.
49
+ * This will allow you to add or remore Items from the mapping lookup
50
+ *
51
+ * ### Example inbound.form_map_before filter
52
+ *
53
+ * This is an example of how form mapping can be filtered and
54
+ * additional fields can be mapped via javascript
55
+ *
56
+ * ```js
57
+ * // Adding the filter function
58
+ * function Inbound_Add_Filter_Example( FieldMapArray ) {
59
+ * var map = FieldMapArray || [];
60
+ * map.push('new lookup value');
61
+ *
62
+ * return map;
63
+ * };
64
+ *
65
+ * // Adding the filter on dom ready
66
+ * _inbound.hooks.addFilter( 'inbound.form_map_before', Inbound_Add_Filter_Example, 10 );
67
+ * ```
68
+ *
69
+ * @return {[type]} [description]
70
+ */
71
+ runFieldMappingFilters: function() {
72
+ FieldMapArray = _inbound.hooks.applyFilters('forms.field_map', FieldMapArray);
73
+ //alert(FieldMapArray);
74
+ },
75
+ debug: function(msg, callback) {
76
+ //if app not in debug mode, exit immediately
77
+ if (!debugMode || !console) {
78
+ return
79
+ };
80
+ var msg = msg || false;
81
+ //console.log the message
82
+ if (msg && (typeof msg === 'string')) {
83
+ console.log(msg)
84
+ };
85
+
86
+ //execute the callback if one was passed-in
87
+ if (callback && (callback instanceof Function)) {
88
+ callback();
89
+ };
90
+ },
91
+ formTrackInit: function() {
92
+
93
+ for (var i = 0; i < window.document.forms.length; i++) {
94
+ var trackForm = false;
95
+ var form = window.document.forms[i];
96
+ /* process forms only once */
97
+ if (!form.dataset.formProcessed) {
98
+ form.dataset.formProcessed = true;
99
+ trackForm = this.checkTrackStatus(form);
100
+ // var trackForm = _inbound.Utils.hasClass("wpl-track-me", form);
101
+ if (trackForm) {
102
+ this.attachFormSubmitEvent(form); /* attach form listener */
103
+ this.initFormMapping(form);
104
+ }
105
+ }
106
+ }
107
+ },
108
+ checkTrackStatus: function(form) {
109
+ var ClassIs = form.getAttribute('class');
110
+ if (ClassIs !== "" && ClassIs !== null) {
111
+ if (ClassIs.toLowerCase().indexOf("wpl-track-me") > -1) {
112
+ return true;
113
+ } else if (ClassIs.toLowerCase().indexOf("inbound-track") > -1) {
114
+ return true;
115
+ } else {
116
+ cb = function(){
117
+ console.log(form);
118
+ }
119
+ _inbound.deBugger('forms', "This form not tracked. Please assign on in settings...", cb);
120
+ return false;
121
+ }
122
+ }
123
+ },
124
+ assignTrackClass: function() {
125
+ if (window.inbound_settings) {
126
+ if (inbound_settings.inbound_track_include) {
127
+ var selectors = inbound_settings.inbound_track_include.split(',');
128
+ var msg = 'add selectors ' + inbound_settings.inbound_track_include;
129
+ _inbound.deBugger('forms', msg);
130
+ this.loopClassSelectors(selectors, 'add');
131
+ }
132
+ if (inbound_settings.inbound_track_exclude) {
133
+ var selectors = inbound_settings.inbound_track_exclude.split(',');
134
+ var msg = 'remove selectors ' + inbound_settings.inbound_track_exclude;
135
+ _inbound.deBugger('forms', msg);
136
+ this.loopClassSelectors(selectors, 'remove');
137
+ }
138
+ }
139
+ },
140
+ /* Loop through include/exclude items for tracking */
141
+ loopClassSelectors: function(selectors, action) {
142
+ for (var i = selectors.length - 1; i >= 0; i--) {
143
+
144
+ //if(selectors[i] match . or # )
145
+ selector = document.querySelector(utils.trim(selectors[i]));
146
+ //console.log("SELECTOR", selector);
147
+ if (selector) {
148
+ if (action === 'add') {
149
+ _inbound.Utils.addClass('wpl-track-me', selector);
150
+ _inbound.Utils.addClass('inbound-track', selector);
151
+ } else {
152
+ _inbound.Utils.removeClass('wpl-track-me', selector);
153
+ _inbound.Utils.removeClass('inbound-track', selector);
154
+ }
155
+ }
156
+ };
157
+ },
158
+ /* Map field fields on load */
159
+ initFormMapping: function(form) {
160
+ var hiddenInputs = [];
161
+
162
+ for (var i = 0; i < form.elements.length; i++) {
163
+ formInput = form.elements[i];
164
+
165
+ if (formInput.type === 'hidden') {
166
+ hiddenInputs.push(formInput);
167
+ continue;
168
+ }
169
+ /* Map form fields */
170
+ this.mapField(formInput);
171
+ /* Remember visible inputs */
172
+ this.rememberInputValues(formInput);
173
+ /* Fill visible inputs */
174
+ if (settings.formAutoPopulation) {
175
+ this.fillInputValues(formInput);
176
+ }
177
+
178
+ }
179
+ for (var i = hiddenInputs.