WordPress Landing Pages - Version 1.7.2

Version Description

  • Improved form email typo detection
  • Improved Template Styles
  • Fixed content wysiwyg scroll freezing bug
Download this release

Release Info

Developer adbox
Plugin Icon 128x128 WordPress Landing Pages
Version 1.7.2
Comparing to
See all releases

Code changes from version 1.7.1 to 1.7.2

Files changed (46) hide show
  1. classes/class.activation.php +1 -1
  2. css/admin-post-edit.css +6 -1
  3. css/admin-style.css +6 -2
  4. js/admin/admin.metaboxes.js +1 -1
  5. landing-pages.php +5 -4
  6. modules/module.javascript-admin.php +1 -1
  7. modules/module.metaboxes-global.php +1 -0
  8. modules/module.redirect-ab-testing.php +5 -4
  9. modules/module.store.php +1 -1
  10. phpunit.xml.dist +2 -2
  11. readme.txt +6 -2
  12. shared/assets/assets.loader.class.php +2 -0
  13. shared/assets/frontend/js/analytics-src/analytics.events.js +116 -116
  14. shared/assets/frontend/js/analytics-src/analytics.forms.js +141 -0
  15. shared/assets/frontend/js/analytics-src/analytics.init.js +42 -41
  16. shared/assets/frontend/js/analytics-src/analytics.lead-tracking.js +383 -425
  17. shared/assets/frontend/js/analytics-src/analytics.load.js +41 -0
  18. shared/assets/frontend/js/analytics-src/analytics.page-tracking.js +172 -172
  19. shared/assets/frontend/js/analytics-src/analytics.storage.js +135 -135
  20. shared/assets/frontend/js/analytics-src/analytics.utils.js +373 -339
  21. shared/assets/frontend/js/analytics-src/form-mapping.js +288 -0
  22. shared/assets/frontend/js/analytics/inboundAnalytics.js +1404 -813
  23. shared/classes/class.form.php +260 -10
  24. shared/classes/class.post-type.email-template.php +5 -1
  25. shared/classes/class.post-type.wp-lead.php +1 -1
  26. shared/classes/class.shortcodes.email-template.php +24 -10
  27. shared/metaboxes/inbound-metaboxes.css +3 -8
  28. shared/shortcodes/inbound-shortcodes.php +2 -6
  29. shared/shortcodes/shortcodes/forms.php +2 -1
  30. shared/shortcodes/shortcodes/lists.php +1 -1
  31. shared/templates/email-templates/token-test/token-test.php +48 -48
  32. shared/templates/email-templates/wp-notify-moderator/wp-notify-moderator.php +8 -8
  33. shared/tracking/store.lead.php +105 -31
  34. templates/countdown-lander/config.php +1 -1
  35. templates/default/config.php +1 -1
  36. templates/dropcap/assets/css/style.css +4 -0
  37. templates/dropcap/index.php +6 -0
  38. templates/simple-solid-lite/config.php +2 -2
  39. templates/simple-solid-lite/css/main.css +18 -2
  40. templates/svtle/assets/css/style.css +9 -21
  41. templates/svtle/config.php +1 -1
  42. templates/svtle/index.php +2 -1
  43. templates/three-column-lander/config.php +1 -1
  44. templates/tubelar/config.php +1 -1
  45. tests/travis-ci/bootstrap.php +29 -0
  46. tests/travis-ci/test.activations.php +50 -0
classes/class.activation.php CHANGED
@@ -25,7 +25,7 @@ class Landing_Pages_Activation {
25
  public static function load_static_vars() {
26
 
27
  self::$version_wp = '3.6';
28
- self::$version_php = '5.3';
29
  self::$version_cta = '1.2.1';
30
  self::$version_leads = '1.2.1';
31
  self::$version_lpah = '1.0.8';
25
  public static function load_static_vars() {
26
 
27
  self::$version_wp = '3.6';
28
+ self::$version_php = '5.2';
29
  self::$version_cta = '1.2.1';
30
  self::$version_leads = '1.2.1';
31
  self::$version_lpah = '1.0.8';
css/admin-post-edit.css CHANGED
@@ -16,6 +16,10 @@ h2#convert-header {
16
  .mceIframeContainer.mceFirst.mceLast iframe{
17
  height: 335px !important;
18
  }
 
 
 
 
19
  #lp-notes-area input {
20
  width: 100%;
21
  color: #AAAAAA;
@@ -102,7 +106,8 @@ min-width: 320px;
102
  padding-top: 3px !important;
103
  right: 0px !important;
104
  height: 31px !important;
105
-
 
106
  }
107
  .jPicker {
108
  display: inline-block;
16
  .mceIframeContainer.mceFirst.mceLast iframe{
17
  height: 335px !important;
18
  }
19
+ /* FIX WORDPRESS BULLSHIT */
20
+ body.modal-open {
21
+ overflow: visible !important;
22
+ }
23
  #lp-notes-area input {
24
  width: 100%;
25
  color: #AAAAAA;
106
  padding-top: 3px !important;
107
  right: 0px !important;
108
  height: 31px !important;
109
+ max-width: 100px !important;
110
+ text-align: center !important;
111
  }
112
  .jPicker {
113
  display: inline-block;
css/admin-style.css CHANGED
@@ -5,11 +5,15 @@
5
  padding-right:60px;
6
  }
7
 
8
- #main-title-area
9
- {
10
  margin-top: 5px;
11
  }
12
 
 
 
 
 
 
13
 
14
  #setting-error-tgmpa p:nth-child(2) strong em {
15
  margin-top: 5px;
5
  padding-right:60px;
6
  }
7
 
8
+ #main-title-area {
 
9
  margin-top: 5px;
10
  }
11
 
12
+ #main-title-area span {
13
+ margin-top:30px;
14
+ z-index:999999;
15
+ }
16
+
17
 
18
  #setting-error-tgmpa p:nth-child(2) strong em {
19
  margin-top: 5px;
js/admin/admin.metaboxes.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function($) {
1
+ jQuery(document).ready(function($) {
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.1
7
  Author: Inbound Now
8
  Author URI: http://www.inboundnow.com/
9
  Text Domain: landing-pages
@@ -37,7 +37,8 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
37
  */
38
  static function fail_php_version() {
39
  //add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain_init' ) );
40
- self::notice( __( 'Landing Pages requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'landing-pages' ) );
 
41
  }
42
 
43
  /**
@@ -101,8 +102,8 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
101
  */
102
  private static function load_constants() {
103
 
104
- define('LANDINGPAGES_CURRENT_VERSION', '1.7.1' );
105
- define('LANDINGPAGES_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
106
  define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
107
  define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
108
  define('LANDINGPAGES_FILE', __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.2
7
  Author: Inbound Now
8
  Author URI: http://www.inboundnow.com/
9
  Text Domain: landing-pages
37
  */
38
  static function fail_php_version() {
39
  //add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain_init' ) );
40
+ $plugin_url = admin_url( 'plugins.php' );
41
+ self::notice( __( 'Landing Pages requires PHP version 5.3+ to run. Your version '.PHP_VERSION.' is not high enough.<br><u>Please contact your hosting provider</u> to upgrade your PHP Version.<br>The plugin is NOT Running. You can disable this warning message by <a href="'.$plugin_url.'">deactivating the plugin</a>', 'landing-pages' ) );
42
  }
43
 
44
  /**
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__) ) );
109
  define('LANDINGPAGES_FILE', __FILE__ );
modules/module.javascript-admin.php CHANGED
@@ -35,7 +35,7 @@ function lp_admin_enqueue($hook) {
35
  if ( in_array( $plugin_page, array( 'lp_store', 'lp_addons' ) ) ) {
36
  wp_dequeue_script('easyXDM');
37
  wp_enqueue_script('easyXDM', LANDINGPAGES_URLPATH . 'js/libraries/easyXDM.debug.js');
38
- //wp_enqueue_script('lp-js-store', LANDINGPAGES_URLPATH . 'js/admin/admin.store.js');
39
  }
40
 
41
  // Admin enqueue - Landing Page CPT only
35
  if ( in_array( $plugin_page, array( 'lp_store', 'lp_addons' ) ) ) {
36
  wp_dequeue_script('easyXDM');
37
  wp_enqueue_script('easyXDM', LANDINGPAGES_URLPATH . 'js/libraries/easyXDM.debug.js');
38
+ wp_enqueue_script('lp-js-store', LANDINGPAGES_URLPATH . 'js/admin/admin.store.js');
39
  }
40
 
41
  // Admin enqueue - Landing Page CPT only
modules/module.metaboxes-global.php CHANGED
@@ -17,6 +17,7 @@ function lp_add_global_meta_box( $post_type )
17
  $exclude[] = 'tracking-event';
18
  $exclude[] = 'inbound-forms';
19
  $exclude[] = 'email-template';
 
20
  $exclude[] = 'inbound-log';
21
  $exclude[] = 'landing-page';
22
  // add filter
17
  $exclude[] = 'tracking-event';
18
  $exclude[] = 'inbound-forms';
19
  $exclude[] = 'email-template';
20
+ $exclude[] = 'inbound-email';
21
  $exclude[] = 'inbound-log';
22
  $exclude[] = 'landing-page';
23
  // add filter
modules/module.redirect-ab-testing.php CHANGED
@@ -40,7 +40,7 @@ class LP_Variation_Rotation {
40
  */
41
  private static function load_variables()
42
  {
43
- self::$permalink_name = (isset($_GET['permalink_name'])) ? $_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();
@@ -62,7 +62,7 @@ class LP_Variation_Rotation {
62
  static function load_post_id() {
63
  global $wpdb;
64
 
65
- $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type='landing-page'", $_GET['permalink_name'] ));
66
 
67
  return $post_id;
68
 
@@ -167,8 +167,9 @@ class LP_Variation_Rotation {
167
  * Redirects to Correct Variation
168
  */
169
  static function redirect() {
170
- @header("HTTP/1.1 307 Temporary Redirect");
171
- @header("Location: ".self::$destination_url);
 
172
  }
173
  }
174
 
40
  */
41
  private static function load_variables()
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();
62
  static function load_post_id() {
63
  global $wpdb;
64
 
65
+ $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type='landing-page'", self::$permalink_name ));
66
 
67
  return $post_id;
68
 
167
  * Redirects to Correct Variation
168
  */
169
  static function redirect() {
170
+ header("HTTP/1.1 302 Temporary Redirect");
171
+ header("Location: ".self::$destination_url);
172
+ exit;
173
  }
174
  }
175
 
modules/module.store.php CHANGED
@@ -1 +1 @@
1
- <?php
1
+ <?php
phpunit.xml.dist CHANGED
@@ -1,8 +1,8 @@
1
- <phpunit bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true">
2
  <testsuites>
3
  <!-- Default test suite to run all tests -->
4
  <testsuite>
5
- <directory prefix="test_" suffix=".php">tests</directory>
6
  </testsuite>
7
  </testsuites>
8
  </phpunit>
1
+ <phpunit bootstrap="tests/travis-ci/bootstrap.php" backupGlobals="false" colors="true">
2
  <testsuites>
3
  <!-- Default test suite to run all tests -->
4
  <testsuite>
5
+ <directory prefix="test." suffix=".php">tests/travis-ci/</directory>
6
  </testsuite>
7
  </testsuites>
8
  </phpunit>
readme.txt CHANGED
@@ -7,7 +7,7 @@ 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.1
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,8 +72,12 @@ 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
 
76
- = 1.7.0 =
77
  * removed iframe of inbound now addon store. For addons please visit: http://inboundnow.com/market
78
 
79
  = 1.7.0 =
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
  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
78
+ * Fixed content wysiwyg scroll freezing bug
79
 
80
+ = 1.7.1 =
81
  * removed iframe of inbound now addon store. For addons please visit: http://inboundnow.com/market
82
 
83
  = 1.7.0 =
shared/assets/assets.loader.class.php CHANGED
@@ -46,6 +46,7 @@ class Inbound_Asset_Loader {
46
 
47
  //self::load_file('script-test', 'admin/js/test.js');
48
  } else {
 
49
  global $wp_scripts;
50
 
51
  if ( !empty( $wp_scripts->queue ) ) {
@@ -56,6 +57,7 @@ class Inbound_Asset_Loader {
56
  }
57
 
58
  self::load_file('funnel-tracking', 'frontend/js/page-tracking.js', array( 'jquery','jquery-cookie', 'jquery-total-storage'), 'wplft', self::localize_lead_data());
 
59
  // TODO: Merge Localize of wplft into inbound_ajax
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
 
46
 
47
  //self::load_file('script-test', 'admin/js/test.js');
48
  } else {
49
+
50
  global $wp_scripts;
51
 
52
  if ( !empty( $wp_scripts->queue ) ) {
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
 
shared/assets/frontend/js/analytics-src/analytics.events.js CHANGED
@@ -1,117 +1,117 @@
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
+ * 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 || {});
shared/assets/frontend/js/analytics-src/analytics.forms.js ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 || {});
shared/assets/frontend/js/analytics-src/analytics.init.js CHANGED
@@ -1,41 +1,42 @@
1
- /**
2
- * Init Inbound Analytics
3
- * - initializes analytics
4
- */
5
-
6
- var Lead_Globals = jQuery.totalStorage('inbound_lead_data') || null;
7
- function setGlobalLeadVar(retString){
8
- Lead_Globals = retString;
9
- }
10
-
11
- InboundAnalytics.init(); // run analytics
12
-
13
- /* run on ready */
14
- jQuery(document).ready(function($) {
15
- //record non conversion status
16
- var in_u = InboundAnalytics.Utils,
17
- wp_lead_uid = in_u.readCookie("wp_lead_uid"),
18
- wp_lead_id = in_u.readCookie("wp_lead_id"),
19
- expire_check = in_u.readCookie("lead_session_expire"); // check for session
20
-
21
- if (expire_check === null) {
22
- console.log('expired vistor. Run Processes');
23
- //var data_to_lookup = global-localized-vars;
24
- if (typeof (wp_lead_id) != "undefined" && wp_lead_id != null && wp_lead_id != "") {
25
- /* Get Lead_Globals */
26
- InboundAnalytics.LeadsAPI.getAllLeadData(expire_check);
27
- /* Lead list check */
28
- InboundAnalytics.LeadsAPI.getLeadLists();
29
- }
30
- }
31
-
32
- //window.addEventListener('load',function(){
33
- // InboundAnalytics.LeadsAPI.attachSubmitEvent(window,InboundAnalytics.LeadsAPI.formSubmit);
34
- //}, false);
35
-
36
- in_u.contentLoaded(window, InboundAnalytics.LeadsAPI.attachFormSubmitEvent);
37
-
38
- /* Set Session Timeout */
39
- in_u.SetSessionTimeout();
40
-
41
- });
 
1
+ /**
2
+ * Lead Tracking JS
3
+ * http://www.inboundnow.com
4
+ * This is the main analytics entry point
5
+ */
6
+
7
+ var inbound_data = inbound_data || {};
8
+ var _inboundOptions = _inboundOptions || {};
9
+ /* Ensure global _gaq Google Analytics queue has been initialized. */
10
+ var _gaq = _gaq || [];
11
+
12
+ var InboundAnalytics = (function (Options) {
13
+
14
+ /* Constants */
15
+ var debugMode = false;
16
+
17
+ var App = {
18
+ /* Initialize individual modules */
19
+ init: function () {
20
+ InboundAnalytics.Utils.init();
21
+ InboundAnalytics.PageTracking.StorePageView();
22
+ InboundAnalytics.Events.loadEvents();
23
+ InboundAnalytics.Forms.init();
24
+ },
25
+ /* Debugger Function toggled by var debugMode */
26
+ debug: function(msg, callback){
27
+ //if app not in debug mode, exit immediately
28
+ if(!debugMode || !console){return};
29
+ var msg = msg || false;
30
+ //console.log the message
31
+ if(msg && (typeof msg === 'string')){console.log(msg)};
32
+
33
+ //execute the callback if one was passed-in
34
+ if(callback && (callback instanceof Function)){
35
+ callback();
36
+ };
37
+ }
38
+ };
39
+
40
+ return App;
41
+
42
+ })(_inboundOptions);
shared/assets/frontend/js/analytics-src/analytics.lead-tracking.js CHANGED
@@ -1,426 +1,384 @@
1
- /**
2
- * Leads API functions
3
- * @param Object InboundAnalytics - Main JS object
4
- * @return Object - include event triggers
5
- */
6
- var InboundAnalyticsLeadsAPI = (function (InboundAnalytics) {
7
- var httpRequest;
8
- InboundAnalytics.LeadsAPI = {
9
- init: function() {
10
-
11
- },
12
- storeLeadData: function(){
13
- if(element.addEventListener) {
14
- element.addEventListener("submit", function(evt){
15
- evt.preventDefault();
16
- window.history.back();
17
- }, true);
18
- } else {
19
- element.attachEvent('onsubmit', function(evt){
20
- evt.preventDefault();
21
- window.history.back();
22
- });
23
- }
24
- },
25
- attachFormSubmitEvent: function (){
26
- for(var i=0; i<window.document.forms.length; i++){
27
- var form = window.document.forms[i];
28
- var className = "wpl-track-me";
29
- if ('classList' in document.documentElement) {
30
- var hasClass = form.classList.contains(className);
31
- } else {
32
- var hasClass = new RegExp('(^|\\s)' + className + '(\\s|$)').test(form.className); /* IE Polyfill */
33
- }
34
- /* is tracked form */
35
- if(hasClass){
36
- console.log("Has Class", hasClass);
37
- InboundAnalytics.Utils.addListener(form, 'submit', InboundAnalytics.LeadsAPI.formSubmit );
38
- console.log(form);
39
- }
40
-
41
- }
42
- console.log("RAN attach event");
43
- },
44
- makeRequest: function(url) {
45
- if (window.XMLHttpRequest) { // Mozilla, Safari, ...
46
- httpRequest = new XMLHttpRequest();
47
- } else if (window.ActiveXObject) { // IE
48
- try {
49
- httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
50
- }
51
- catch (e) {
52
- try {
53
- httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
54
- }
55
- catch (e) {}
56
- }
57
- }
58
-
59
- if (!httpRequest) {
60
- alert('Giving up :( Cannot create an XMLHTTP instance');
61
- return false;
62
- }
63
- httpRequest.onreadystatechange = InboundAnalytics.LeadsAPI.alertContents;
64
- httpRequest.open('GET', url);
65
- httpRequest.send();
66
- },
67
- inbound_map_fields: function (el, value, Obj) {
68
- var formObj = [];
69
- var $this = el;
70
- var clean_output = value;
71
- var label = $this.closest('label').text();
72
- var exclude = ['credit-card']; // exlcude values from formObj
73
- var inarray = jQuery.inArray(clean_output, exclude);
74
- if(inarray == 0){
75
- return null;
76
- }
77
- // Add items to formObj
78
- formObj.push({
79
- field_label: label,
80
- field_name: $this.attr("name"),
81
- field_value: $this.attr("value"),
82
- field_id: $this.attr("id"),
83
- field_class: $this.attr("class"),
84
- field_type: $this.attr("type"),
85
- match: clean_output,
86
- js_selector: $this.attr("data-js-selector")
87
- });
88
- return formObj;
89
- },
90
- run_field_map_function: function (el, lookingfor) {
91
- var return_form;
92
- var formObj = new Array();
93
- var $this = el;
94
- var body = jQuery("body");
95
- var input_id = $this.attr("id") || "NULL";
96
- var input_name = $this.attr("name") || "NULL";
97
- var this_val = $this.attr("value");
98
- var array = lookingfor.split(",");
99
- var array_length = array.length - 1;
100
-
101
- // Main Loop
102
- for (var i = 0; i < array.length; i++) {
103
- var clean_output = InboundAnalytics.Utils.trim(array[i]);
104
- var nice_name = clean_output.replace(/^\s+|\s+$/g,'');
105
- var nice_name = nice_name.replace(" ",'_');
106
- var in_object_already = nice_name in inbound_data;
107
- //console.log(clean_output);
108
-
109
- if (input_name.toLowerCase().indexOf(clean_output)>-1) {
110
- /* Look for attr name match */
111
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
112
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
113
- console.log('match name: ' + clean_output);
114
- console.log(nice_name in inbound_data);
115
- if (!in_object_already) {
116
- inbound_data[nice_name] = this_val;
117
- }
118
- } else if (input_id.toLowerCase().indexOf(clean_output)>-1) {
119
- /* look for id match */
120
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
121
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
122
- console.log('match id: ' + clean_output);
123
-
124
- if (!in_object_already) {
125
- inbound_data[nice_name] = this_val;
126
- }
127
-
128
- } else if ($this.closest('li').children('label').length>0) {
129
- /* Look for label name match */
130
- var closest_label = $this.closest('li').children('label').html() || "NULL";
131
- if (closest_label.toLowerCase().indexOf(clean_output)>-1) {
132
-
133
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
134
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
135
- console.log($this.context);
136
-
137
- var exists_in_dom = body.find("[data-inbound-form-map='inbound_map_" + nice_name + "']").length;
138
- console.log(exists_in_dom);
139
- console.log('match li: ' + clean_output);
140
-
141
- if (!in_object_already) {
142
- inbound_data[nice_name] = this_val;
143
- }
144
-
145
- }
146
- } else if ($this.closest('div').children('label').length>0) {
147
- /* Look for closest div label name match */
148
- var closest_div = $this.closest('div').children('label').html() || "NULL";
149
- if (closest_div.toLowerCase().indexOf(clean_output)>-1)
150
- {
151
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
152
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
153
- console.log('match div: ' + clean_output);
154
- if (!in_object_already) {
155
- inbound_data[nice_name] = this_val;
156
- }
157
- }
158
- } else if ($this.closest('p').children('label').length>0) {
159
- /* Look for closest p label name match */
160
- var closest_p = $this.closest('p').children('label').html() || "NULL";
161
- if (closest_p.toLowerCase().indexOf(clean_output)>-1)
162
- {
163
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
164
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
165
- console.log('match p: ' + clean_output);
166
- if (!in_object_already) {
167
- inbound_data[nice_name] = this_val;
168
- }
169
- }
170
- } else {
171
- console.log('Need additional mapping data');
172
- }
173
- }
174
- return_form = the_map;
175
-
176
- return inbound_data;
177
- },
178
- add_inbound_form_class: function(el, value) {
179
- var value = value.replace(" ", "_");
180
- var value = value.replace("-", "_");
181
- el.addClass('inbound_map_value');
182
- el.attr('data-inbound-form-map', 'inbound_map_' + value);
183
- },
184
- inbound_form_type: function(this_form) {
185
- var inbound_data = inbound_data || {},
186
- form_type = 'normal';
187
- if ( this_form.is( ".wpl-comment-form" ) ) {
188
- inbound_data['form_type'] = 'comment';
189
- form_type = 'comment';
190
- } else if ( this_form.is( ".wpl-search-box" ) ) {
191
- var is_search = true;
192
- form_type = 'search';
193
- inbound_data['form_type'] = 'search';
194
- } else if ( this_form.is( '.wpl-track-me-link' ) ){
195
- var have_email = readCookie('wp_lead_email');
196
- console.log(have_email);
197
- inbound_data['form_type'] = 'link';
198
- form_type = 'search';
199
- }
200
- return form_type;
201
- },
202
- grab_all_form_input_vals: function(this_form){
203
- var post_values = post_values || {},
204
- inbound_exclude = inbound_exclude || [],
205
- form_inputs = this_form.find('input,textarea,select');
206
- inbound_exclude.push('inbound_furl', 'inbound_current_page_url', 'inbound_notify', 'inbound_submitted', 'post_type', 'post_status', 's', 'inbound_form_name', 'inbound_form_id', 'inbound_form_lists');
207
- var form_type = InboundAnalytics.LeadsAPI.inbound_form_type(this_form),
208
- inbound_data = inbound_data || {},
209
- email = inbound_data['email'] || false;
210
-
211
- form_inputs.each(function() {
212
- var $input = jQuery(this),
213
- input_type = $input.attr('type'),
214
- input_val = $input.val();
215
- if (input_type === 'checkbox') {
216
- input_checked = $input.attr("checked");
217
- console.log(input_val);
218
- console.log(input_checked);
219
- console.log(post_values[this.name]);
220
- if (input_checked === "checked"){
221
- if (typeof (post_values[this.name]) != "undefined") {
222
- post_values[this.name] = post_values[this.name] + "," + input_val;
223
- console.log(post_values[this.name]);
224
- } else {
225
- post_values[this.name] = input_val;
226
- }
227
-
228
- }
229
- }
230
- if (jQuery.inArray(this.name, inbound_exclude) === -1 && input_type != 'checkbox'){
231
- post_values[this.name] = input_val;
232
- }
233
- if (this.value.indexOf('@')>-1&&!email){
234
- email = input_val;
235
- inbound_data['email'] = email;
236
- }
237
- if (form_type === 'search') {
238
- inbound_data['search_keyword'] = input_val.replace('"', "'");
239
- }
240
- });
241
- var all_form_fields = JSON.stringify(post_values);
242
- return all_form_fields;
243
- },
244
- return_mapped_values: function (this_form) {
245
- // Map form fields
246
- jQuery(this_form).find('input[type!="hidden"],textarea,select').each(function() {
247
- console.log('run');
248
- var this_input = jQuery(this);
249
- var this_input_val = this_input.val();
250
- if (typeof (this_input_val) != "undefined" && this_input_val != null && this_input_val != "") {
251
- var inbound_data = InboundAnalytics.LeadsAPI.run_field_map_function( this_input, "name, first name, last name, email, e-mail, phone, website, job title, company, tele, address, comment");
252
- }
253
- return inbound_data;
254
- });
255
- return inbound_data;
256
- },
257
- inbound_form_submit: function(this_form, e) {
258
- /* Define Variables */
259
- var data = inbound_data || {};
260
- // Dynamic JS object for passing custom values. This can be hooked into by third parties by using the below syntax.
261
- var pageviewObj = jQuery.totalStorage('page_views');
262
- data['page_view_count'] = InboundAnalytics.Utils.countProperties(pageviewObj);
263
- data['leads_list'] = jQuery(this_form).find('#inbound_form_lists').val();
264
- data['source'] = jQuery.cookie("wp_lead_referral_site") || "NA";
265
- data['page_id'] = inbound_ajax.post_id;
266
- data['page_views'] = JSON.stringify(pageviewObj);
267
-
268
- // Map form fields
269
- var returned_form_data = InboundAnalytics.LeadsAPI.return_mapped_values(this_form); //console.log(returned_form_data);
270
- var data = InboundAnalytics.Utils.mergeObjs(data,returned_form_data); //console.log(data);
271
- var this_form = jQuery(this_form);
272
- // Set variables after mapping
273
- data['email'] = (!data['email']) ? this_form.find('.inbound-email').val() : data['email'];
274
- data['form_name'] = this_form.find('.inbound_form_name').val() || "Not Found";
275
- data['form_id'] = this_form.find('.inbound_form_id').val() || "Not Found";
276
- data['first_name'] = (!data['first_name']) ? data['name'] : data['first_name'];
277
- data['last_name'] = data['last_name'] || '';
278
- data['phone'] = data['phone'] || '';
279
- data['company'] = data['company'] || '';
280
- data['address'] = data['address'] || '';
281
-
282
- // Fallbacks for values
283
- data['name'] = (data['first_name'] && data['last_name']) ? data['first_name'] + " " + data['last_name'] : data['name'];
284
-
285
- if (!data['last_name'] && data['first_name']) {
286
- var parts = data['first_name'].split(" ");
287
- data['first_name'] = parts[0];
288
- data['last_name'] = parts[1];
289
- }
290
-
291
- /* Store form fields & exclude field values */
292
- var all_form_fields = InboundAnalytics.LeadsAPI.grab_all_form_input_vals(this_form);
293
- /* end Store form fields & exclude field values */
294
-
295
- if(data['email']){
296
- InboundAnalytics.Utils.createCookie("wp_lead_email", data['email'], 365); /* set email cookie */
297
- }
298
-
299
- //var variation = (typeof (landing_path_info) != "undefined") ? landing_path_info.variation : false;
300
-
301
- if (typeof (landing_path_info) != "undefined") {
302
- var variation = landing_path_info.variation;
303
- } else if (typeof (cta_path_info) != "undefined") {
304
- var variation = cta_path_info.variation;
305
- } else {
306
- var variation = 0;
307
- }
308
-
309
- data['variation'] = variation;
310
- data['post_type'] = inbound_ajax.post_type;
311
- data['wp_lead_uid'] = jQuery.cookie("wp_lead_uid") || null;
312
- data['ip_address'] = inbound_ajax.ip_address;
313
- data['search_data'] = JSON.stringify(jQuery.totalStorage('inbound_search')) || {};
314
-
315
- var lp_check = (inbound_ajax.post_type === 'landing-page') ? 'Landing Page' : "";
316
- var cta_check = (inbound_ajax.post_type === 'wp-call-to-action') ? 'Call to Action' : "";
317
- var page_type = (!cta_check && !lp_check) ? inbound_ajax.post_type : lp_check + cta_check;
318
-
319
- // jsonify data
320
- var mapped_form_data = JSON.stringify(data);
321
-
322
- var return_data = {};
323
- var return_data = {
324
- "action": 'inbound_store_lead',
325
- "emailTo": data['email'],
326
- "first_name": data['first_name'],
327
- "last_name": data['last_name'],
328
- "phone": data['phone'],
329
- "address": data['address'],
330
- "company_name": data['company'],
331
- "page_views": data['page_views'],
332
- "form_input_values": all_form_fields,
333
- "Mapped_Data": mapped_form_data,
334
- "Search_Data": data['search_data']
335
- }
336
- return return_data;
337
- },
338
- formSubmit: function (e){
339
- /*if(!confirm('Are you sure?')) {
340
- e.returnValue = false;
341
- if(e.preventDefault) e.preventDefault();
342
- return false;
343
- }
344
- return true;*/
345
- /*var inbound_data = inbound_data || {},
346
- this_form = e.target,
347
- event_type = e.type,
348
- is_search = false,
349
- form_type = 'normal';*/
350
-
351
- e.preventDefault(); /* Halt form processing */
352
- console.log("This works");
353
- var data = InboundAnalytics.LeadsAPI.inbound_form_submit(e.target, e); // big function for processing
354
- console.log(data);
355
- alert('Working');
356
- //document.getElementById("ajaxButton").onclick = function() { makeRequest('test.html'); };
357
-
358
- /* Final Ajax Call on Submit */
359
- InboundAnalytics.LeadsAPI.makeRequest('test.html');
360
- },
361
- alertContents: function() {
362
- if (httpRequest.readyState === 4) {
363
- if (httpRequest.status === 200) {
364
- alert(httpRequest.responseText);
365
- } else if(xmlhttp.status == 400) {
366
- alert('There was an error 400');
367
- } else {
368
- alert('There was a problem with the request.');
369
- }
370
- }
371
- },
372
- getAllLeadData: function(expire_check) {
373
- var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id"),
374
- old_data = jQuery.totalStorage('inbound_lead_data'),
375
- data = {
376
- action: 'inbound_get_all_lead_data',
377
- wp_lead_id: wp_lead_id,
378
- },
379
- success = function(returnData){
380
- var obj = JSON.parse(returnData);
381
- console.log('RAAAAAAn');
382
- setGlobalLeadVar(obj);
383
- jQuery.totalStorage('inbound_lead_data', obj); // store lead data
384
- };
385
-
386
- if(!old_data) {
387
- console.log("No old data");
388
- }
389
-
390
- if (expire_check === 'true'){
391
- console.log("Session has not expired");
392
- }
393
-
394
- if(!old_data && expire_check === null) {
395
- InboundAnalytics.debug('Go to Database',function(){
396
- console.log(expire_check);
397
- console.log(old_data);
398
- });
399
- InboundAnalytics.Utils.doAjax(data, success);
400
- } else {
401
- setGlobalLeadVar(old_data); // set global lead var with localstorage data
402
- var lead_data_expiration = InboundAnalytics.Utils.readCookie("lead_data_expiration");
403
- if (lead_data_expiration === null) {
404
- InboundAnalytics.Utils.doAjax(data, success);
405
- console.log('localized data old. Pull new from DB');
406
- }
407
- }
408
-
409
- },
410
- getLeadLists: function() {
411
- var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id");
412
- var data = {
413
- action: 'wpl_check_lists',
414
- wp_lead_id: wp_lead_id,
415
- };
416
- var success = function(user_id){
417
- jQuery.cookie("lead_session_list_check", true, { path: '/', expires: 1 });
418
- console.log("Lists checked");
419
- };
420
- InboundAnalytics.Utils.doAjax(data, success);
421
- }
422
- };
423
-
424
- return InboundAnalytics;
425
-
426
  })(InboundAnalytics || {});
1
+ /**
2
+ * Leads API functions
3
+ * @param Object InboundAnalytics - Main JS object
4
+ * @return Object - include event triggers
5
+ */
6
+ var InboundAnalyticsLeadsAPI = (function (InboundAnalytics) {
7
+ var httpRequest;
8
+ InboundAnalytics.LeadsAPI = {
9
+ init: function() {
10
+
11
+ },
12
+ storeLeadData: function(){
13
+ if(element.addEventListener) {
14
+ element.addEventListener("submit", function(evt){
15
+ evt.preventDefault();
16
+ window.history.back();
17
+ }, true);
18
+ } else {
19
+ element.attachEvent('onsubmit', function(evt){
20
+ evt.preventDefault();
21
+ window.history.back();
22
+ });
23
+ }
24
+ },
25
+ inbound_map_fields: function (el, value, Obj) {
26
+ var formObj = [];
27
+ var $this = el;
28
+ var clean_output = value;
29
+ var label = $this.closest('label').text();
30
+ var exclude = ['credit-card']; // exlcude values from formObj
31
+ var inarray = jQuery.inArray(clean_output, exclude);
32
+ if(inarray == 0){
33
+ return null;
34
+ }
35
+ // Add items to formObj
36
+ formObj.push({
37
+ field_label: label,
38
+ field_name: $this.attr("name"),
39
+ field_value: $this.attr("value"),
40
+ field_id: $this.attr("id"),
41
+ field_class: $this.attr("class"),
42
+ field_type: $this.attr("type"),
43
+ match: clean_output,
44
+ js_selector: $this.attr("data-js-selector")
45
+ });
46
+ return formObj;
47
+ },
48
+ run_field_map_function: function (el, lookingfor) {
49
+ var return_form;
50
+ var formObj = new Array();
51
+ var $this = el;
52
+ var body = jQuery("body");
53
+ var input_id = $this.attr("id") || "NULL";
54
+ var input_name = $this.attr("name") || "NULL";
55
+ var this_val = $this.attr("value");
56
+ var array = lookingfor.split(",");
57
+ var array_length = array.length - 1;
58
+
59
+ // Main Loop
60
+ for (var i = 0; i < array.length; i++) {
61
+ var clean_output = InboundAnalytics.Utils.trim(array[i]);
62
+ var nice_name = clean_output.replace(/^\s+|\s+$/g,'');
63
+ var nice_name = nice_name.replace(" ",'_');
64
+ var in_object_already = nice_name in inbound_data;
65
+ //console.log(clean_output);
66
+
67
+ if (input_name.toLowerCase().indexOf(clean_output)>-1) {
68
+ /* Look for attr name match */
69
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
70
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
71
+ console.log('match name: ' + clean_output);
72
+ console.log(nice_name in inbound_data);
73
+ if (!in_object_already) {
74
+ inbound_data[nice_name] = this_val;
75
+ }
76
+ } else if (input_id.toLowerCase().indexOf(clean_output)>-1) {
77
+ /* look for id match */
78
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
79
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
80
+ console.log('match id: ' + clean_output);
81
+
82
+ if (!in_object_already) {
83
+ inbound_data[nice_name] = this_val;
84
+ }
85
+
86
+ } else if ($this.closest('li').children('label').length>0) {
87
+ /* Look for label name match */
88
+ var closest_label = $this.closest('li').children('label').html() || "NULL";
89
+ if (closest_label.toLowerCase().indexOf(clean_output)>-1) {
90
+
91
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
92
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
93
+ console.log($this.context);
94
+
95
+ var exists_in_dom = body.find("[data-inbound-form-map='inbound_map_" + nice_name + "']").length;
96
+ console.log(exists_in_dom);
97
+ console.log('match li: ' + clean_output);
98
+
99
+ if (!in_object_already) {
100
+ inbound_data[nice_name] = this_val;
101
+ }
102
+
103
+ }
104
+ } else if ($this.closest('div').children('label').length>0) {
105
+ /* Look for closest div label name match */
106
+ var closest_div = $this.closest('div').children('label').html() || "NULL";
107
+ if (closest_div.toLowerCase().indexOf(clean_output)>-1)
108
+ {
109
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
110
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
111
+ console.log('match div: ' + clean_output);
112
+ if (!in_object_already) {
113
+ inbound_data[nice_name] = this_val;
114
+ }
115
+ }
116
+ } else if ($this.closest('p').children('label').length>0) {
117
+ /* Look for closest p label name match */
118
+ var closest_p = $this.closest('p').children('label').html() || "NULL";
119
+ if (closest_p.toLowerCase().indexOf(clean_output)>-1)
120
+ {
121
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
122
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
123
+ console.log('match p: ' + clean_output);
124
+ if (!in_object_already) {
125
+ inbound_data[nice_name] = this_val;
126
+ }
127
+ }
128
+ } else {
129
+ console.log('Need additional mapping data');
130
+ }
131
+ }
132
+ return_form = the_map;
133
+
134
+ return inbound_data;
135
+ },
136
+ add_inbound_form_class: function(el, value) {
137
+ var value = value.replace(" ", "_");
138
+ var value = value.replace("-", "_");
139
+ el.addClass('inbound_map_value');
140
+ el.attr('data-inbound-form-map', 'inbound_map_' + value);
141
+ },
142
+ inbound_form_type: function(this_form) {
143
+ var inbound_data = inbound_data || {},
144
+ form_type = 'normal';
145
+ if ( this_form.is( ".wpl-comment-form" ) ) {
146
+ inbound_data['form_type'] = 'comment';
147
+ form_type = 'comment';
148
+ } else if ( this_form.is( ".wpl-search-box" ) ) {
149
+ var is_search = true;
150
+ form_type = 'search';
151
+ inbound_data['form_type'] = 'search';
152
+ } else if ( this_form.is( '.wpl-track-me-link' ) ){
153
+ var have_email = readCookie('wp_lead_email');
154
+ console.log(have_email);
155
+ inbound_data['form_type'] = 'link';
156
+ form_type = 'search';
157
+ }
158
+ return form_type;
159
+ },
160
+ grab_all_form_input_vals: function(this_form){
161
+ var post_values = post_values || {},
162
+ inbound_exclude = inbound_exclude || [],
163
+ form_inputs = this_form.find('input,textarea,select');
164
+ inbound_exclude.push('inbound_furl', 'inbound_current_page_url', 'inbound_notify', 'inbound_submitted', 'post_type', 'post_status', 's', 'inbound_form_name', 'inbound_form_id', 'inbound_form_lists');
165
+ var form_type = InboundAnalytics.LeadsAPI.inbound_form_type(this_form),
166
+ inbound_data = inbound_data || {},
167
+ email = inbound_data['email'] || false;
168
+
169
+ form_inputs.each(function() {
170
+ var $input = jQuery(this),
171
+ input_type = $input.attr('type'),
172
+ input_val = $input.val();
173
+ if (input_type === 'checkbox') {
174
+ input_checked = $input.attr("checked");
175
+ console.log(input_val);
176
+ console.log(input_checked);
177
+ console.log(post_values[this.name]);
178
+ if (input_checked === "checked"){
179
+ if (typeof (post_values[this.name]) != "undefined") {
180
+ post_values[this.name] = post_values[this.name] + "," + input_val;
181
+ console.log(post_values[this.name]);
182
+ } else {
183
+ post_values[this.name] = input_val;
184
+ }
185
+
186
+ }
187
+ }
188
+ if (jQuery.inArray(this.name, inbound_exclude) === -1 && input_type != 'checkbox'){
189
+ post_values[this.name] = input_val;
190
+ }
191
+ if (this.value.indexOf('@')>-1&&!email){
192
+ email = input_val;
193
+ inbound_data['email'] = email;
194
+ }
195
+ if (form_type === 'search') {
196
+ inbound_data['search_keyword'] = input_val.replace('"', "'");
197
+ }
198
+ });
199
+ var all_form_fields = JSON.stringify(post_values);
200
+ return all_form_fields;
201
+ },
202
+ return_mapped_values: function (this_form) {
203
+ // Map form fields
204
+ jQuery(this_form).find('input[type!="hidden"],textarea,select').each(function() {
205
+ console.log('run');
206
+ var this_input = jQuery(this);
207
+ var this_input_val = this_input.val();
208
+ if (typeof (this_input_val) != "undefined" && this_input_val != null && this_input_val != "") {
209
+ var inbound_data = InboundAnalytics.LeadsAPI.run_field_map_function( this_input, "name, first name, last name, email, e-mail, phone, website, job title, company, tele, address, comment");
210
+ }
211
+ return inbound_data;
212
+ });
213
+ return inbound_data;
214
+ },
215
+ inbound_form_submit: function(this_form, e) {
216
+ /* Define Variables */
217
+ var data = inbound_data || {};
218
+ // Dynamic JS object for passing custom values. This can be hooked into by third parties by using the below syntax.
219
+ var pageviewObj = jQuery.totalStorage('page_views');
220
+ data['page_view_count'] = InboundAnalytics.Utils.countProperties(pageviewObj);
221
+ data['leads_list'] = jQuery(this_form).find('#inbound_form_lists').val();
222
+ data['source'] = jQuery.cookie("wp_lead_referral_site") || "NA";
223
+ data['page_id'] = inbound_ajax.post_id;
224
+ data['page_views'] = JSON.stringify(pageviewObj);
225
+
226
+ // Map form fields
227
+ var returned_form_data = InboundAnalytics.LeadsAPI.return_mapped_values(this_form); //console.log(returned_form_data);
228
+ var data = InboundAnalytics.Utils.mergeObjs(data,returned_form_data); //console.log(data);
229
+ var this_form = jQuery(this_form);
230
+ // Set variables after mapping
231
+ data['email'] = (!data['email']) ? this_form.find('.inbound-email').val() : data['email'];
232
+ data['form_name'] = this_form.find('.inbound_form_name').val() || "Not Found";
233
+ data['form_id'] = this_form.find('.inbound_form_id').val() || "Not Found";
234
+ data['first_name'] = (!data['first_name']) ? data['name'] : data['first_name'];
235
+ data['last_name'] = data['last_name'] || '';
236
+ data['phone'] = data['phone'] || '';
237
+ data['company'] = data['company'] || '';
238
+ data['address'] = data['address'] || '';
239
+
240
+ // Fallbacks for values
241
+ data['name'] = (data['first_name'] && data['last_name']) ? data['first_name'] + " " + data['last_name'] : data['name'];
242
+
243
+ if (!data['last_name'] && data['first_name']) {
244
+ var parts = data['first_name'].split(" ");
245
+ data['first_name'] = parts[0];
246
+ data['last_name'] = parts[1];
247
+ }
248
+
249
+ /* Store form fields & exclude field values */
250
+ var all_form_fields = InboundAnalytics.LeadsAPI.grab_all_form_input_vals(this_form);
251
+ /* end Store form fields & exclude field values */
252
+
253
+ if(data['email']){
254
+ InboundAnalytics.Utils.createCookie("wp_lead_email", data['email'], 365); /* set email cookie */
255
+ }
256
+
257
+ //var variation = (typeof (landing_path_info) != "undefined") ? landing_path_info.variation : false;
258
+
259
+ if (typeof (landing_path_info) != "undefined") {
260
+ var variation = landing_path_info.variation;
261
+ } else if (typeof (cta_path_info) != "undefined") {
262
+ var variation = cta_path_info.variation;
263
+ } else {
264
+ var variation = 0;
265
+ }
266
+
267
+ data['variation'] = variation;
268
+ data['post_type'] = inbound_ajax.post_type;
269
+ data['wp_lead_uid'] = jQuery.cookie("wp_lead_uid") || null;
270
+ data['ip_address'] = inbound_ajax.ip_address;
271
+ data['search_data'] = JSON.stringify(jQuery.totalStorage('inbound_search')) || {};
272
+
273
+ var lp_check = (inbound_ajax.post_type === 'landing-page') ? 'Landing Page' : "";
274
+ var cta_check = (inbound_ajax.post_type === 'wp-call-to-action') ? 'Call to Action' : "";
275
+ var page_type = (!cta_check && !lp_check) ? inbound_ajax.post_type : lp_check + cta_check;
276
+
277
+ // jsonify data
278
+ var mapped_form_data = JSON.stringify(data);
279
+
280
+ var return_data = {};
281
+ var return_data = {
282
+ "action": 'inbound_store_lead',
283
+ "emailTo": data['email'],
284
+ "first_name": data['first_name'],
285
+ "last_name": data['last_name'],
286
+ "phone": data['phone'],
287
+ "address": data['address'],
288
+ "company_name": data['company'],
289
+ "page_views": data['page_views'],
290
+ "form_input_values": all_form_fields,
291
+ "Mapped_Data": mapped_form_data,
292
+ "Search_Data": data['search_data']
293
+ }
294
+ return return_data;
295
+ },
296
+ formSubmit: function (e){
297
+ /*if(!confirm('Are you sure?')) {
298
+ e.returnValue = false;
299
+ if(e.preventDefault) e.preventDefault();
300
+ return false;
301
+ }
302
+ return true;*/
303
+ /*var inbound_data = inbound_data || {},
304
+ this_form = e.target,
305
+ event_type = e.type,
306
+ is_search = false,
307
+ form_type = 'normal';*/
308
+
309
+ e.preventDefault(); /* Halt form processing */
310
+ console.log("This works");
311
+ var data = InboundAnalytics.LeadsAPI.inbound_form_submit(e.target, e); // big function for processing
312
+ console.log(data);
313
+ alert('Working');
314
+ //document.getElementById("ajaxButton").onclick = function() { makeRequest('test.html'); };
315
+
316
+ /* Final Ajax Call on Submit */
317
+ InboundAnalytics.LeadsAPI.makeRequest('test.html');
318
+ },
319
+ alertContents: function() {
320
+ if (httpRequest.readyState === 4) {
321
+ if (httpRequest.status === 200) {
322
+ alert(httpRequest.responseText);
323
+ } else if(xmlhttp.status == 400) {
324
+ alert('There was an error 400');
325
+ } else {
326
+ alert('There was a problem with the request.');
327
+ }
328
+ }
329
+ },
330
+ getAllLeadData: function(expire_check) {
331
+ var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id"),
332
+ old_data = jQuery.totalStorage('inbound_lead_data'),
333
+ data = {
334
+ action: 'inbound_get_all_lead_data',
335
+ wp_lead_id: wp_lead_id,
336
+ },
337
+ success = function(returnData){
338
+ var obj = JSON.parse(returnData);
339
+ console.log('Got all the lead data check ');
340
+ setGlobalLeadVar(obj);
341
+ jQuery.totalStorage('inbound_lead_data', obj); // store lead data
342
+ };
343
+
344
+ if(!old_data) {
345
+ console.log("No old data");
346
+ }
347
+
348
+ if (expire_check === 'true'){
349
+ console.log("Session has not expired");
350
+ }
351
+
352
+ if(!old_data && expire_check === null) {
353
+ InboundAnalytics.debug('Go to Database',function(){
354
+ console.log(expire_check);
355
+ console.log(old_data);
356
+ });
357
+ InboundAnalytics.Utils.doAjax(data, success);
358
+ } else {
359
+ setGlobalLeadVar(old_data); // set global lead var with localstorage data
360
+ var lead_data_expiration = InboundAnalytics.Utils.readCookie("lead_data_expiration");
361
+ if (lead_data_expiration === null) {
362
+ InboundAnalytics.Utils.doAjax(data, success);
363
+ console.log('localized data old. Pull new from DB');
364
+ }
365
+ }
366
+
367
+ },
368
+ getLeadLists: function() {
369
+ var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id");
370
+ var data = {
371
+ action: 'wpl_check_lists',
372
+ wp_lead_id: wp_lead_id,
373
+ };
374
+ var success = function(user_id){
375
+ jQuery.cookie("lead_session_list_check", true, { path: '/', expires: 1 });
376
+ console.log("Lists checked");
377
+ };
378
+ InboundAnalytics.Utils.doAjax(data, success);
379
+ }
380
+ };
381
+
382
+ return InboundAnalytics;
383
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  })(InboundAnalytics || {});
shared/assets/frontend/js/analytics-src/analytics.load.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Init Inbound Analytics
3
+ * - initializes analytics
4
+ */
5
+
6
+ var InboundLeadData = jQuery.totalStorage('inbound_lead_data') || null;
7
+ function setGlobalLeadVar(retString){
8
+ InboundLeadData = retString;
9
+ }
10
+
11
+ InboundAnalytics.init(); // run analytics
12
+
13
+ /* run on ready */
14
+ jQuery(document).ready(function($) {
15
+ //record non conversion status
16
+ var in_u = InboundAnalytics.Utils,
17
+ wp_lead_uid = in_u.readCookie("wp_lead_uid"),
18
+ wp_lead_id = in_u.readCookie("wp_lead_id"),
19
+ expire_check = in_u.readCookie("lead_session_expire"); // check for session
20
+
21
+ if (expire_check === null) {
22
+ console.log('expired vistor. Run Processes');
23
+ //var data_to_lookup = global-localized-vars;
24
+ if (typeof (wp_lead_id) != "undefined" && wp_lead_id != null && wp_lead_id != "") {
25
+ /* Get InboundLeadData */
26
+ InboundAnalytics.LeadsAPI.getAllLeadData(expire_check);
27
+ /* Lead list check */
28
+ InboundAnalytics.LeadsAPI.getLeadLists();
29
+ }
30
+ }
31
+
32
+ //window.addEventListener('load',function(){
33
+ // InboundAnalytics.LeadsAPI.attachSubmitEvent(window,InboundAnalytics.LeadsAPI.formSubmit);
34
+ //}, false);
35
+
36
+ in_u.contentLoaded(window, InboundAnalytics.LeadsAPI.attachFormSubmitEvent);
37
+
38
+ /* Set Session Timeout */
39
+ in_u.SetSessionTimeout();
40
+
41
+ });
shared/assets/frontend/js/analytics-src/analytics.page-tracking.js CHANGED
@@ -1,173 +1,173 @@
1
- var InboundAnalyticsPageTracking = (function (InboundAnalytics) {
2
-
3
- InboundAnalytics.PageTracking = {
4
-
5
- getPageViews: function () {
6
- var local_store = InboundAnalytics.Utils.checkLocalStorage();
7
- if(local_store){
8
- var page_views = localStorage.getItem("page_views"),
9
- local_object = JSON.parse(page_views);
10
- if (typeof local_object =='object' && local_object) {
11
- this.StorePageView();
12
- }
13
- return local_object;
14
- }
15
- },
16
- StorePageView: function() {
17
- var timeout = this.CheckTimeOut();
18
- var pageviewObj = jQuery.totalStorage('page_views');
19
- if(pageviewObj === null) {
20
- pageviewObj = {};
21
- }
22
- var current_page_id = wplft.post_id;
23
- var datetime = InboundAnalytics.Utils.GetDate();
24
-
25
- if (timeout) {
26
- // If pageviewObj exists, do this
27
- var page_seen = pageviewObj[current_page_id];
28
-
29
- if(typeof(page_seen) != "undefined" && page_seen !== null) {
30
- pageviewObj[current_page_id].push(datetime);
31
- /* Page Revisit Trigger */
32
- var page_seen_count = pageviewObj[current_page_id].length;
33
- InboundAnalytics.Events.pageRevisit(page_seen_count);
34
-
35
- } else {
36
- pageviewObj[current_page_id] = [];
37
- pageviewObj[current_page_id].push(datetime);
38
- /* Page First Seen Trigger */
39
- var page_seen_count = 1;
40
- InboundAnalytics.Events.pageFirstView(page_seen_count);
41
- }
42
-
43
- jQuery.totalStorage('page_views', pageviewObj);
44
-
45
- }
46
- },
47
- CheckTimeOut: function() {
48
- var PageViews = jQuery.totalStorage('page_views');
49
- if(PageViews === null) {
50
- var PageViews = {};
51
- }
52
- var page_id = wplft.post_id,
53
- pageviewTimeout = true, /* Default */
54
- page_seen = PageViews[page_id];
55
- if(typeof(page_seen) != "undefined" && page_seen !== null) {
56
-
57
- var time_now = InboundAnalytics.Utils.GetDate(),
58
- vc = PageViews[page_id].length - 1,
59
- last_view = PageViews[page_id][vc],
60
- last_view_ms = new Date(last_view).getTime(),
61
- time_now_ms = new Date(time_now).getTime(),
62
- timeout_ms = last_view_ms + 30*1000,
63
- time_check = Math.abs(last_view_ms - time_now_ms),
64
- wait_time = 30000;
65
-
66
- InboundAnalytics.debug('Timeout Checks =',function(){
67
- console.log('Current Time is: ' + time_now);
68
- console.log('Last view is: ' + last_view);
69
- console.log("Last view milliseconds " + last_view_ms);
70
- console.log("time now milliseconds " + time_now_ms);
71
- console.log("Wait Check: " + wait_time);
72
- console.log("TIME CHECK: " + time_check);
73
- });
74
-
75
- //var wait_time = Math.abs(last_view_ms - timeout_ms) // output timeout time 30sec;
76
-
77
- if (time_check < wait_time){
78
- time_left = Math.abs((wait_time - time_check)) * .001;
79
- pageviewTimeout = false;
80
- var status = '30 sec timeout not done: ' + time_left + " seconds left";
81
- } else {
82
- var status = 'Timeout Happened. Page view fired';
83
- this.firePageView();
84
- pageviewTimeout = true;
85
- InboundAnalytics.Events.analyticsTriggered();
86
- }
87
-
88
- //InboundAnalytics.debug('',function(){
89
- console.log(status);
90
- //});
91
- } else {
92
- /* Page never seen before */
93
- this.firePageView();
94
- }
95
-
96
- return pageviewTimeout;
97
-
98
- },
99
- firePageView: function() {
100
- var lead_id = InboundAnalytics.Utils.readCookie('wp_lead_id'),
101
- lead_uid = InboundAnalytics.Utils.readCookie('wp_lead_uid');
102
-
103
- if (typeof (lead_id) != "undefined" && lead_id != null && lead_id != "") {
104
-
105
- InboundAnalytics.debug('Run page view ajax');
106
-
107
- var data = {
108
- action: 'wpl_track_user',
109
- wp_lead_uid: lead_uid,
110
- wp_lead_id: lead_id,
111
- page_id: wplft.post_id,
112
- current_url: window.location.href,
113
- json: '0'
114
- };
115
- var firePageCallback = function(user_id){
116
- InboundAnalytics.Events.analyticsSaved();
117
- };
118
- InboundAnalytics.Utils.doAjax(data, firePageCallback);
119
- }
120
- },
121
- tabSwitch: function() {
122
- /* test out simplier script
123
- function onBlur() {
124
- document.body.className = 'blurred';
125
- };
126
- function onFocus(){
127
- document.body.className = 'focused';
128
- };
129
-
130
- if (false) { // check for Internet Explorer
131
- document.onfocusin = onFocus;
132
- document.onfocusout = onBlur;
133
- } else {
134
- window.onfocus = onFocus;
135
- window.onblur = onBlur;
136
- }
137
- */
138
-
139
- var hidden, visibilityState, visibilityChange;
140
-
141
- if (typeof document.hidden !== "undefined") {
142
- hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
143
- } else if (typeof document.mozHidden !== "undefined") {
144
- hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
145
- } else if (typeof document.msHidden !== "undefined") {
146
- hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
147
- } else if (typeof document.webkitHidden !== "undefined") {
148
- hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
149
- } // if
150
-
151
- var document_hidden = document[hidden];
152
-
153
- document.addEventListener(visibilityChange, function() {
154
- if(document_hidden != document[hidden]) {
155
- if(document[hidden]) {
156
- // Document hidden
157
- console.log('hidden');
158
- InboundAnalytics.Events.browserTabHidden();
159
- } else {
160
- // Document shown
161
- console.log('shown');
162
- InboundAnalytics.Events.browserTabVisible();
163
- } // if
164
-
165
- document_hidden = document[hidden];
166
- } // if
167
- });
168
- }
169
- }
170
-
171
- return InboundAnalytics;
172
-
173
  })(InboundAnalytics || {});
1
+ var InboundAnalyticsPageTracking = (function (InboundAnalytics) {
2
+
3
+ InboundAnalytics.PageTracking = {
4
+
5
+ getPageViews: function () {
6
+ var local_store = InboundAnalytics.Utils.checkLocalStorage();
7
+ if(local_store){
8
+ var page_views = localStorage.getItem("page_views"),
9
+ local_object = JSON.parse(page_views);
10
+ if (typeof local_object =='object' && local_object) {
11
+ this.StorePageView();
12
+ }
13
+ return local_object;
14
+ }
15
+ },
16
+ StorePageView: function() {
17
+ var timeout = this.CheckTimeOut();
18
+ var pageviewObj = jQuery.totalStorage('page_views');
19
+ if(pageviewObj === null) {
20
+ pageviewObj = {};
21
+ }
22
+ var current_page_id = wplft.post_id;
23
+ var datetime = InboundAnalytics.Utils.GetDate();
24
+
25
+ if (timeout) {
26
+ // If pageviewObj exists, do this
27
+ var page_seen = pageviewObj[current_page_id];
28
+
29
+ if(typeof(page_seen) != "undefined" && page_seen !== null) {
30
+ pageviewObj[current_page_id].push(datetime);
31
+ /* Page Revisit Trigger */
32
+ var page_seen_count = pageviewObj[current_page_id].length;
33
+ InboundAnalytics.Events.pageRevisit(page_seen_count);
34
+
35
+ } else {
36
+ pageviewObj[current_page_id] = [];
37
+ pageviewObj[current_page_id].push(datetime);
38
+ /* Page First Seen Trigger */
39
+ var page_seen_count = 1;
40
+ InboundAnalytics.Events.pageFirstView(page_seen_count);
41
+ }
42
+
43
+ jQuery.totalStorage('page_views', pageviewObj);
44
+
45
+ }
46
+ },
47
+ CheckTimeOut: function() {
48
+ var PageViews = jQuery.totalStorage('page_views');
49
+ if(PageViews === null) {
50
+ var PageViews = {};
51
+ }
52
+ var page_id = wplft.post_id,
53
+ pageviewTimeout = true, /* Default */
54
+ page_seen = PageViews[page_id];
55
+ if(typeof(page_seen) != "undefined" && page_seen !== null) {
56
+
57
+ var time_now = InboundAnalytics.Utils.GetDate(),
58
+ vc = PageViews[page_id].length - 1,
59
+ last_view = PageViews[page_id][vc],
60
+ last_view_ms = new Date(last_view).getTime(),
61
+ time_now_ms = new Date(time_now).getTime(),
62
+ timeout_ms = last_view_ms + 30*1000,
63
+ time_check = Math.abs(last_view_ms - time_now_ms),
64
+ wait_time = 30000;
65
+
66
+ InboundAnalytics.debug('Timeout Checks =',function(){
67
+ console.log('Current Time is: ' + time_now);
68
+ console.log('Last view is: ' + last_view);
69
+ console.log("Last view milliseconds " + last_view_ms);
70
+ console.log("time now milliseconds " + time_now_ms);
71
+ console.log("Wait Check: " + wait_time);
72
+ console.log("TIME CHECK: " + time_check);
73
+ });
74
+
75
+ //var wait_time = Math.abs(last_view_ms - timeout_ms) // output timeout time 30sec;
76
+
77
+ if (time_check < wait_time){
78
+ time_left = Math.abs((wait_time - time_check)) * .001;
79
+ pageviewTimeout = false;
80
+ var status = '30 sec timeout not done: ' + time_left + " seconds left";
81
+ } else {
82
+ var status = 'Timeout Happened. Page view fired';
83
+ this.firePageView();
84
+ pageviewTimeout = true;
85
+ InboundAnalytics.Events.analyticsTriggered();
86
+ }
87
+
88
+ //InboundAnalytics.debug('',function(){
89
+ console.log(status);
90
+ //});
91
+ } else {
92
+ /* Page never seen before */
93
+ this.firePageView();
94
+ }
95
+
96
+ return pageviewTimeout;
97
+
98
+ },
99
+ firePageView: function() {
100
+ var lead_id = InboundAnalytics.Utils.readCookie('wp_lead_id'),
101
+ lead_uid = InboundAnalytics.Utils.readCookie('wp_lead_uid');
102
+
103
+ if (typeof (lead_id) != "undefined" && lead_id != null && lead_id != "") {
104
+
105
+ InboundAnalytics.debug('Run page view ajax');
106
+
107
+ var data = {
108
+ action: 'wpl_track_user',
109
+ wp_lead_uid: lead_uid,
110
+ wp_lead_id: lead_id,
111
+ page_id: wplft.post_id,
112
+ current_url: window.location.href,
113
+ json: '0'
114
+ };
115
+ var firePageCallback = function(user_id){
116
+ InboundAnalytics.Events.analyticsSaved();
117
+ };
118
+ InboundAnalytics.Utils.doAjax(data, firePageCallback);
119
+ }
120
+ },
121
+ tabSwitch: function() {
122
+ /* test out simplier script
123
+ function onBlur() {
124
+ document.body.className = 'blurred';
125
+ };
126
+ function onFocus(){
127
+ document.body.className = 'focused';
128
+ };
129
+
130
+ if (false) { // check for Internet Explorer
131
+ document.onfocusin = onFocus;
132
+ document.onfocusout = onBlur;
133
+ } else {
134
+ window.onfocus = onFocus;
135
+ window.onblur = onBlur;
136
+ }
137
+ */
138
+
139
+ var hidden, visibilityState, visibilityChange;
140
+
141
+ if (typeof document.hidden !== "undefined") {
142
+ hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
143
+ } else if (typeof document.mozHidden !== "undefined") {
144
+ hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
145
+ } else if (typeof document.msHidden !== "undefined") {
146
+ hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
147
+ } else if (typeof document.webkitHidden !== "undefined") {
148
+ hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
149
+ } // if
150
+
151
+ var document_hidden = document[hidden];
152
+
153
+ document.addEventListener(visibilityChange, function() {
154
+ if(document_hidden != document[hidden]) {
155
+ if(document[hidden]) {
156
+ // Document hidden
157
+ console.log('hidden');
158
+ InboundAnalytics.Events.browserTabHidden();
159
+ } else {
160
+ // Document shown
161
+ console.log('shown');
162
+ InboundAnalytics.Events.browserTabVisible();
163
+ } // if
164
+
165
+ document_hidden = document[hidden];
166
+ } // if
167
+ });
168
+ }
169
+ }
170
+
171
+ return InboundAnalytics;
172
+
173
  })(InboundAnalytics || {});
shared/assets/frontend/js/analytics-src/analytics.storage.js CHANGED
@@ -1,136 +1,136 @@
1
- /* Fork of jquery.total-storage.js */
2
- var InboundTotalStorage = (function (InboundAnalytics){
3
-
4
- /* Variables I'll need throghout */
5
-
6
- var supported, ls, mod = 'inboundAnalytics';
7
- if ('localStorage' in window){
8
- try {
9
- ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
10
- if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
11
- supported = false;
12
- } else {
13
- supported = true;
14
- }
15
- window.localStorage.setItem(mod, '1');
16
- window.localStorage.removeItem(mod);
17
- }
18
- catch (err){
19
- supported = false;
20
- }
21
- }
22
-
23
- /* Make the methods public */
24
- InboundAnalytics.totalStorage = function(key, value, options){
25
- return InboundAnalytics.totalStorage.impl.init(key, value);
26
- };
27
-
28
- InboundAnalytics.totalStorage.setItem = function(key, value){
29
- return InboundAnalytics.totalStorage.impl.setItem(key, value);
30
- };
31
-
32
- InboundAnalytics.totalStorage.getItem = function(key){
33
- return InboundAnalytics.totalStorage.impl.getItem(key);
34
- };
35
-
36
- InboundAnalytics.totalStorage.getAll = function(){
37
- return InboundAnalytics.totalStorage.impl.getAll();
38
- };
39
-
40
- InboundAnalytics.totalStorage.deleteItem = function(key){
41
- return InboundAnalytics.totalStorage.impl.deleteItem(key);
42
- };
43
-
44
- /* Object to hold all methods: public and private */
45
-
46
- InboundAnalytics.totalStorage.impl = {
47
-
48
- init: function(key, value){
49
- if (typeof value != 'undefined') {
50
- return this.setItem(key, value);
51
- } else {
52
- return this.getItem(key);
53
- }
54
- },
55
-
56
- setItem: function(key, value){
57
- if (!supported){
58
- try {
59
- InboundAnalytics.Utils.createCookie(key, value);
60
- return value;
61
- } catch(e){
62
- console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');
63
- }
64
- }
65
- var saver = JSON.stringify(value);
66
- ls.setItem(key, saver);
67
- return this.parseResult(saver);
68
- },
69
- getItem: function(key){
70
- if (!supported){
71
- try {
72
- return this.parseResult(InboundAnalytics.Utils.readCookie(key));
73
- } catch(e){
74
- return null;
75
- }
76
- }
77
- var item = ls.getItem(key);
78
- return this.parseResult(item);
79
- },
80
- deleteItem: function(key){
81
- if (!supported){
82
- try {
83
- InboundAnalytics.Utils.eraseCookie(key, null);
84
- return true;
85
- } catch(e){
86
- return false;
87
- }
88
- }
89
- ls.removeItem(key);
90
- return true;
91
- },
92
- getAll: function(){
93
- var items = [];
94
- if (!supported){
95
- try {
96
- var pairs = document.cookie.split(";");
97
- for (var i = 0; i<pairs.length; i++){
98
- var pair = pairs[i].split('=');
99
- var key = pair[0];
100
- items.push({key:key, value:this.parseResult(InboundAnalytics.Utils.readCookie(key))});
101
- }
102
- } catch(e){
103
- return null;
104
- }
105
- } else {
106
- for (var j in ls){
107
- if (j.length){
108
- items.push({key:j, value:this.parseResult(ls.getItem(j))});
109
- }
110
- }
111
- }
112
- return items;
113
- },
114
- parseResult: function(res){
115
- var ret;
116
- try {
117
- ret = JSON.parse(res);
118
- if (typeof ret == 'undefined'){
119
- ret = res;
120
- }
121
- if (ret == 'true'){
122
- ret = true;
123
- }
124
- if (ret == 'false'){
125
- ret = false;
126
- }
127
- if (parseFloat(ret) == ret && typeof ret != "object"){
128
- ret = parseFloat(ret);
129
- }
130
- } catch(e){
131
- ret = res;
132
- }
133
- return ret;
134
- }
135
- };
136
  })(InboundAnalytics || {});
1
+ /* Fork of jquery.total-storage.js */
2
+ var InboundTotalStorage = (function (InboundAnalytics){
3
+
4
+ /* Variables I'll need throghout */
5
+
6
+ var supported, ls, mod = 'inboundAnalytics';
7
+ if ('localStorage' in window){
8
+ try {
9
+ ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
10
+ if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
11
+ supported = false;
12
+ } else {
13
+ supported = true;
14
+ }
15
+ window.localStorage.setItem(mod, '1');
16
+ window.localStorage.removeItem(mod);
17
+ }
18
+ catch (err){
19
+ supported = false;
20
+ }
21
+ }
22
+
23
+ /* Make the methods public */
24
+ InboundAnalytics.totalStorage = function(key, value, options){
25
+ return InboundAnalytics.totalStorage.impl.init(key, value);
26
+ };
27
+
28
+ InboundAnalytics.totalStorage.setItem = function(key, value){
29
+ return InboundAnalytics.totalStorage.impl.setItem(key, value);
30
+ };
31
+
32
+ InboundAnalytics.totalStorage.getItem = function(key){
33
+ return InboundAnalytics.totalStorage.impl.getItem(key);
34
+ };
35
+
36
+ InboundAnalytics.totalStorage.getAll = function(){
37
+ return InboundAnalytics.totalStorage.impl.getAll();
38
+ };
39
+
40
+ InboundAnalytics.totalStorage.deleteItem = function(key){
41
+ return InboundAnalytics.totalStorage.impl.deleteItem(key);
42
+ };
43
+
44
+ /* Object to hold all methods: public and private */
45
+
46
+ InboundAnalytics.totalStorage.impl = {
47
+
48
+ init: function(key, value){
49
+ if (typeof value != 'undefined') {
50
+ return this.setItem(key, value);
51
+ } else {
52
+ return this.getItem(key);
53
+ }
54
+ },
55
+
56
+ setItem: function(key, value){
57
+ if (!supported){
58
+ try {
59
+ InboundAnalytics.Utils.createCookie(key, value);
60
+ return value;
61
+ } catch(e){
62
+ console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');
63
+ }
64
+ }
65
+ var saver = JSON.stringify(value);
66
+ ls.setItem(key, saver);
67
+ return this.parseResult(saver);
68
+ },
69
+ getItem: function(key){
70
+ if (!supported){
71
+ try {
72
+ return this.parseResult(InboundAnalytics.Utils.readCookie(key));
73
+ } catch(e){
74
+ return null;
75
+ }
76
+ }
77
+ var item = ls.getItem(key);
78
+ return this.parseResult(item);
79
+ },
80
+ deleteItem: function(key){
81
+ if (!supported){
82
+ try {
83
+ InboundAnalytics.Utils.eraseCookie(key, null);
84
+ return true;
85
+ } catch(e){
86
+ return false;
87
+ }
88
+ }
89
+ ls.removeItem(key);
90
+ return true;
91
+ },
92
+ getAll: function(){
93
+ var items = [];
94
+ if (!supported){
95
+ try {
96
+ var pairs = document.cookie.split(";");
97
+ for (var i = 0; i<pairs.length; i++){
98
+ var pair = pairs[i].split('=');
99
+ var key = pair[0];
100
+ items.push({key:key, value:this.parseResult(InboundAnalytics.Utils.readCookie(key))});
101
+ }
102
+ } catch(e){
103
+ return null;
104
+ }
105
+ } else {
106
+ for (var j in ls){
107
+ if (j.length){
108
+ items.push({key:j, value:this.parseResult(ls.getItem(j))});
109
+ }
110
+ }
111
+ }
112
+ return items;
113
+ },
114
+ parseResult: function(res){
115
+ var ret;
116
+ try {
117
+ ret = JSON.parse(res);
118
+ if (typeof ret == 'undefined'){
119
+ ret = res;
120
+ }
121
+ if (ret == 'true'){
122
+ ret = true;
123
+ }
124
+ if (ret == 'false'){
125
+ ret = false;
126
+ }
127
+ if (parseFloat(ret) == ret && typeof ret != "object"){
128
+ ret = parseFloat(ret);
129
+ }
130
+ } catch(e){
131
+ ret = res;
132
+ }
133
+ return ret;
134
+ }
135
+ };
136
  })(InboundAnalytics || {});
shared/assets/frontend/js/analytics-src/analytics.utils.js CHANGED
@@ -1,340 +1,374 @@
1
- /**
2
- * Utility functions
3
- * @param Object InboundAnalytics - Main JS object
4
- * include util functions
5
- */
6
- var InboundAnalyticsUtils = (function (InboundAnalytics) {
7
-
8
- InboundAnalytics.Utils = {
9
- init: function() {
10
- this.polyFills();
11
- this.setUrlParams();
12
- this.SetUID();
13
- this.getReferer();
14
-
15
- },
16
- polyFills: function() {
17
- /* Console.log fix for old browsers */
18
- if (!window.console) { window.console = {}; }
19
- var m = [
20
- "log", "info", "warn", "error", "debug", "trace", "dir", "group",
21
- "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
22
- "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
23
- ];
24
- // define undefined methods as noops to prevent errors
25
- for (var i = 0; i < m.length; i++) {
26
- if (!window.console[m[i]]) {
27
- window.console[m[i]] = function() {};
28
- }
29
- }
30
- /* Event trigger polyfill for IE9 and 10 */
31
- (function () {
32
- function CustomEvent ( event, params ) {
33
- params = params || { bubbles: false, cancelable: false, detail: undefined };
34
- var evt = document.createEvent( 'CustomEvent' );
35
- evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
36
- return evt;
37
- };
38
-
39
- CustomEvent.prototype = window.Event.prototype;
40
-
41
- window.CustomEvent = CustomEvent;
42
- })();
43
- },
44
- // Create cookie
45
- createCookie: function(name, value, days, custom_time) {
46
- var expires = "";
47
- if (days) {
48
- var date = new Date();
49
- date.setTime(date.getTime()+(days*24*60*60*1000));
50
- expires = "; expires="+date.toGMTString();
51
- }
52
- if(custom_time){
53
- expires = "; expires="+days.toGMTString();
54
- }
55
- document.cookie = name+"="+value+expires+"; path=/";
56
- },
57
- // Read cookie
58
- readCookie: function(name) {
59
- var nameEQ = name + "=";
60
- var ca = document.cookie.split(';');
61
- for(var i=0;i < ca.length;i++) {
62
- var c = ca[i];
63
- while (c.charAt(0) === ' ') {
64
- c = c.substring(1,c.length);
65
- }
66
- if (c.indexOf(nameEQ) === 0) {
67
- return c.substring(nameEQ.length,c.length);
68
- }
69
- }
70
- return null;
71
- },
72
- // Erase cookie
73
- eraseCookie: function(name) {
74
- createCookie(name,"",-1);
75
- },
76
- getAllCookies: function(){
77
- var cookies = {};
78
- if (document.cookie && document.cookie != '') {
79
- var split = document.cookie.split(';');
80
- for (var i = 0; i < split.length; i++) {
81
- var name_value = split[i].split("=");
82
- name_value[0] = name_value[0].replace(/^ /, '');
83
- cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
84
- }
85
- }
86
- jQuery.totalStorage('inbound_cookies', cookies); // store cookie data
87
- return cookies;
88
- },
89
- /* Grab URL params and save */
90
- setUrlParams: function() {
91
- var urlParams = {},
92
- local_store = InboundAnalytics.Utils.checkLocalStorage();
93
-
94
- (function () {
95
- var e,
96
- d = function (s) { return decodeURIComponent(s).replace(/\+/g, " "); },
97
- q = window.location.search.substring(1),
98
- r = /([^&=]+)=?([^&]*)/g;
99
-
100
- while (e = r.exec(q)) {
101
- if (e[1].indexOf("[") == "-1")
102
- urlParams[d(e[1])] = d(e[2]);
103
- else {
104
- var b1 = e[1].indexOf("["),
105
- aN = e[1].slice(b1+1, e[1].indexOf("]", b1)),
106
- pN = d(e[1].slice(0, b1));
107
-
108
- if (typeof urlParams[pN] != "object")
109
- urlParams[d(pN)] = {},
110
- urlParams[d(pN)].length = 0;
111
-
112
- if (aN)
113
- urlParams[d(pN)][d(aN)] = d(e[2]);
114
- else
115
- Array.prototype.push.call(urlParams[d(pN)], d(e[2]));
116
-
117
- }
118
- }
119
- })();
120
-
121
- if (JSON) {
122
- for (var k in urlParams) {
123
- if (typeof urlParams[k] == "object") {
124
- for (var k2 in urlParams[k])
125
- this.createCookie(k2, urlParams[k][k2], 30);
126
- } else {
127
- this.createCookie(k, urlParams[k], 30);
128
- }
129
- }
130
- }
131
-
132
- if(local_store){
133
- var pastParams = jQuery.totalStorage('inbound_url_params');
134
- var params = this.mergeObjs(pastParams, urlParams);
135
- jQuery.totalStorage('inbound_url_params', params); // store cookie data
136
- }
137
- },
138
- getUrlParams: function(){
139
- var local_store = this.checkLocalStorage(),
140
- get_params = {};
141
- if(local_store){
142
- var get_params = jQuery.totalStorage('inbound_url_params');
143
- }
144
- return get_params;
145
- },
146
- // Check local storage
147
- // provate browsing safari fix https://github.com/marcuswestin/store.js/issues/42#issuecomment-25274685
148
- checkLocalStorage: function() {
149
- if ('localStorage' in window) {
150
- try {
151
- ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
152
- if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
153
- supported = false;
154
- } else {
155
- supported = true;
156
- }
157
-
158
- }
159
- catch (err){
160
- supported = false;
161
- }
162
- }
163
- return supported;
164
- /* http://spin.atomicobject.com/2013/01/23/ios-private-browsing-localstorage/
165
- var hasStorage;
166
- hasStorage = function() {
167
- var mod, result;
168
- try {
169
- mod = new Date;
170
- localStorage.setItem(mod, mod.toString());
171
- result = localStorage.getItem(mod) === mod.toString();
172
- localStorage.removeItem(mod);
173
- return result;
174
- } catch (_error) {}
175
- };
176
- */
177
- },
178
- /* Add days to datetime */
179
- addDays: function(myDate,days) {
180
- return new Date(myDate.getTime() + days*24*60*60*1000);
181
- },
182
- GetDate: function(){
183
- var time_now = new Date(),
184
- day = time_now.getDate() + 1;
185
- year = time_now.getFullYear(),
186
- hour = time_now.getHours(),
187
- minutes = time_now.getMinutes(),
188
- seconds = time_now.getSeconds(),
189
- month = time_now.getMonth() + 1;
190
- if (month < 10) { month = '0' + month; }
191
- InboundAnalytics.debug('Current Date:',function(){
192
- console.log(year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds);
193
- });
194
- var datetime = year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds;
195
- return datetime;
196
- },
197
- /* Set Expiration Date of Session Logging */
198
- SetSessionTimeout: function(){
199
- var session_check = this.readCookie("lead_session_expire");
200
- //console.log(session_check);
201
- if(session_check === null){
202
- InboundAnalytics.Events.sessionStart(); // trigger 'inbound_analytics_session_start'
203
- } else {
204
- InboundAnalytics.Events.sessionActive(); // trigger 'inbound_analytics_session_active'
205
- }
206
- var d = new Date();
207
- d.setTime(d.getTime() + 30*60*1000);
208
-
209
- this.createCookie("lead_session_expire", true, d, true); // Set cookie on page loads
210
- var lead_data_expiration = this.readCookie("lead_data_expiration");
211
- if (lead_data_expiration === null){
212
- /* Set 3 day timeout for checking DB for new lead data for Lead_Global var */
213
- var ex = this.addDays(d, 3);
214
- this.createCookie("lead_data_expiration", ex, ex, true);
215
- }
216
-
217
- },
218
- getReferer: function(){
219
- //console.log(expire_time);
220
- var d = new Date();
221
- d.setTime(d.getTime() + 30*60*1000);
222
- var referrer_cookie = InboundAnalytics.Utils.readCookie("wp_lead_referral_site");
223
- if (typeof (referrer_cookie) === "undefined" || referrer_cookie === null || referrer_cookie === "") {
224
- var referrer = document.referrer || "NA";
225
- this.createCookie("wp_lead_referral_site", referrer, d, true); // Set cookie on page loads
226
- }
227
- },
228
- CreateUID: function(length) {
229
- var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''),
230
- str = '';
231
- if (! length) {
232
- length = Math.floor(Math.random() * chars.length);
233
- }
234
- for (var i = 0; i < length; i++) {
235
- str += chars[Math.floor(Math.random() * chars.length)];
236
- }
237
- return str;
238
- },
239
- SetUID: function () {
240
- /* Set Lead UID */
241
-
242
- if(this.readCookie("wp_lead_uid") === null) {
243
- var wp_lead_uid = this.CreateUID(35);
244
- this.createCookie("wp_lead_uid", wp_lead_uid );
245
- InboundAnalytics.debug('Set UID');
246
- }
247
- },
248
- /* Count number of session visits */
249
- countProperties: function (obj) {
250
- var count = 0;
251
- for(var prop in obj) {
252
- if(obj.hasOwnProperty(prop))
253
- ++count;
254
- }
255
- return count;
256
- },
257
- mergeObjs: function(obj1,obj2){
258
- var obj3 = {};
259
- for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
260
- for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
261
- return obj3;
262
- },
263
- trim: function(s) {
264
- s = s.replace(/(^\s*)|(\s*$)/gi,"");
265
- s = s.replace(/[ ]{2,}/gi," ");
266
- s = s.replace(/\n /,"\n"); return s;
267
- },
268
- doAjax: function(data, responseHandler, method, async){
269
- // Set the variables
270
- var url = wplft.admin_url || "",
271
- method = method || "POST",
272
- async = async || true,
273
- data = data || null,
274
- action = data.action;
275
-
276
- InboundAnalytics.debug('Ajax Processed:',function(){
277
- console.log('ran ajax action: ' + action);
278
- });
279
-
280
- jQuery.ajax({
281
- type: method,
282
- url: wplft.admin_url,
283
- data: data,
284
- success: responseHandler,
285
- error: function(MLHttpRequest, textStatus, errorThrown){
286
- console.log(MLHttpRequest+' '+errorThrown+' '+textStatus);
287
- InboundAnalytics.Events.analyticsError(MLHttpRequest, textStatus, errorThrown);
288
- }
289
-
290
- });
291
- },
292
- contentLoaded: function(win, fn) {
293
-
294
- var done = false, top = true,
295
-
296
- doc = win.document, root = doc.documentElement,
297
-
298
- add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
299
- rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
300
- pre = doc.addEventListener ? '' : 'on',
301
-
302
- init = function(e) {
303
- if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
304
- (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
305
- if (!done && (done = true)) fn.call(win, e.type || e);
306
- },
307
-
308
- poll = function() {
309
- try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
310
- init('poll');
311
- };
312
-
313
- if (doc.readyState == 'complete') fn.call(win, 'lazy');
314
- else {
315
- if (doc.createEventObject && root.doScroll) {
316
- try { top = !win.frameElement; } catch(e) { }
317
- if (top) poll();
318
- }
319
- doc[add](pre + 'DOMContentLoaded', init, false);
320
- doc[add](pre + 'readystatechange', init, false);
321
- win[add](pre + 'load', init, false);
322
- }
323
-
324
- },
325
- /* Cross-browser event listening */
326
- addListener: function(obj, eventName, listener) {
327
- if(obj.addEventListener) {
328
- obj.addEventListener(eventName, listener, false);
329
- } else if (obj.attachEvent) {
330
- obj.attachEvent("on" + eventName, listener);
331
- } else {
332
- obj['on' + eventName] = listener;
333
- }
334
- }
335
-
336
- };
337
-
338
- return InboundAnalytics;
339
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  })(InboundAnalytics || {});
1
+ /**
2
+ * Utility functions
3
+ * @param Object InboundAnalytics - Main JS object
4
+ * include util functions
5
+ */
6
+ var InboundAnalyticsUtils = (function (InboundAnalytics) {
7
+
8
+ InboundAnalytics.Utils = {
9
+ init: function() {
10
+ this.polyFills();
11
+ this.setUrlParams();
12
+ this.SetUID();
13
+ this.getReferer();
14
+
15
+ },
16
+ /* Polyfills for missing browser functionality */
17
+ polyFills: function() {
18
+ /* Console.log fix for old browsers */
19
+ if (!window.console) { window.console = {}; }
20
+ var m = [
21
+ "log", "info", "warn", "error", "debug", "trace", "dir", "group",
22
+ "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
23
+ "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
24
+ ];
25
+ // define undefined methods as noops to prevent errors
26
+ for (var i = 0; i < m.length; i++) {
27
+ if (!window.console[m[i]]) {
28
+ window.console[m[i]] = function() {};
29
+ }
30
+ }
31
+ /* Event trigger polyfill for IE9 and 10 */
32
+ (function () {
33
+ function CustomEvent ( event, params ) {
34
+ params = params || { bubbles: false, cancelable: false, detail: undefined };
35
+ var evt = document.createEvent( 'CustomEvent' );
36
+ evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
37
+ return evt;
38
+ };
39
+
40
+ CustomEvent.prototype = window.Event.prototype;
41
+
42
+ window.CustomEvent = CustomEvent;
43
+ })();
44
+ },
45
+ // Create cookie
46
+ createCookie: function(name, value, days, custom_time) {
47
+ var expires = "";
48
+ if (days) {
49
+ var date = new Date();
50
+ date.setTime(date.getTime()+(days*24*60*60*1000));
51
+ expires = "; expires="+date.toGMTString();
52
+ }
53
+ if(custom_time){
54
+ expires = "; expires="+days.toGMTString();
55
+ }
56
+ document.cookie = name+"="+value+expires+"; path=/";
57
+ },
58
+ /* Read cookie */
59
+ readCookie: function(name) {
60
+ var nameEQ = name + "=";
61
+ var ca = document.cookie.split(';');
62
+ for(var i=0;i < ca.length;i++) {
63
+ var c = ca[i];
64
+ while (c.charAt(0) === ' ') {
65
+ c = c.substring(1,c.length);
66
+ }
67
+ if (c.indexOf(nameEQ) === 0) {
68
+ return c.substring(nameEQ.length,c.length);
69
+ }
70
+ }
71
+ return null;
72
+ },
73
+ /* Erase cookies */
74
+ eraseCookie: function(name) {
75
+ createCookie(name,"",-1);
76
+ },
77
+ /* Get All Cookies */
78
+ getAllCookies: function(){
79
+ var cookies = {};
80
+ if (document.cookie && document.cookie != '') {
81
+ var split = document.cookie.split(';');
82
+ for (var i = 0; i < split.length; i++) {
83
+ var name_value = split[i].split("=");
84
+ name_value[0] = name_value[0].replace(/^ /, '');
85
+ cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
86
+ }
87
+ }
88
+ jQuery.totalStorage('inbound_cookies', cookies); // store cookie data
89
+ return cookies;
90
+ },
91
+ /* Grab URL params and save */
92
+ setUrlParams: function() {
93
+ var urlParams = {},
94
+ local_store = this.checkLocalStorage();
95
+
96
+ (function () {
97
+ var e,
98
+ d = function (s) { return decodeURIComponent(s).replace(/\+/g, " "); },
99
+ q = window.location.search.substring(1),
100
+ r = /([^&=]+)=?([^&]*)/g;
101
+
102
+ while (e = r.exec(q)) {
103
+ if (e[1].indexOf("[") == "-1")
104
+ urlParams[d(e[1])] = d(e[2]);
105
+ else {
106
+ var b1 = e[1].indexOf("["),
107
+ aN = e[1].slice(b1+1, e[1].indexOf("]", b1)),
108
+ pN = d(e[1].slice(0, b1));
109
+
110
+ if (typeof urlParams[pN] != "object")
111
+ urlParams[d(pN)] = {},
112
+ urlParams[d(pN)].length = 0;
113
+
114
+ if (aN)
115
+ urlParams[d(pN)][d(aN)] = d(e[2]);
116
+ else
117
+ Array.prototype.push.call(urlParams[d(pN)], d(e[2]));
118
+
119
+ }
120
+ }
121
+ })();
122
+
123
+ if (JSON) {
124
+ for (var k in urlParams) {
125
+ if (typeof urlParams[k] == "object") {
126
+ for (var k2 in urlParams[k])
127
+ this.createCookie(k2, urlParams[k][k2], 30);
128
+ } else {
129
+ this.createCookie(k, urlParams[k], 30);
130
+ }
131
+ }
132
+ }
133
+
134
+ if(local_store){
135
+ var pastParams = jQuery.totalStorage('inbound_url_params');
136
+ var params = this.mergeObjs(pastParams, urlParams);
137
+ jQuery.totalStorage('inbound_url_params', params); // store cookie data
138
+ }
139
+ },
140
+ getUrlParams: function(){
141
+ var local_store = this.checkLocalStorage(),
142
+ get_params = {};
143
+ if(local_store){
144
+ var get_params = jQuery.totalStorage('inbound_url_params');
145
+ }
146
+ return get_params;
147
+ },
148
+ // Check local storage
149
+ // provate browsing safari fix https://github.com/marcuswestin/store.js/issues/42#issuecomment-25274685
150
+ checkLocalStorage: function() {
151
+ if ('localStorage' in window) {
152
+ try {
153
+ ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
154
+ if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
155
+ supported = false;
156
+ } else {
157
+ supported = true;
158
+ }
159
+
160
+ }
161
+ catch (err){
162
+ supported = false;
163
+ }
164
+ }
165
+ return supported;
166
+ /* http://spin.atomicobject.com/2013/01/23/ios-private-browsing-localstorage/
167
+ var hasStorage;
168
+ hasStorage = function() {
169
+ var mod, result;
170
+ try {
171
+ mod = new Date;
172
+ localStorage.setItem(mod, mod.toString());
173
+ result = localStorage.getItem(mod) === mod.toString();
174
+ localStorage.removeItem(mod);
175
+ return result;
176
+ } catch (_error) {}
177
+ };
178
+ */
179
+ },
180
+ /* Add days to datetime */
181
+ addDays: function(myDate,days) {
182
+ return new Date(myDate.getTime() + days*24*60*60*1000);
183
+ },
184
+ GetDate: function(){
185
+ var time_now = new Date(),
186
+ day = time_now.getDate() + 1;
187
+ year = time_now.getFullYear(),
188
+ hour = time_now.getHours(),
189
+ minutes = time_now.getMinutes(),
190
+ seconds = time_now.getSeconds(),
191
+ month = time_now.getMonth() + 1;
192
+ if (month < 10) { month = '0' + month; }
193
+ InboundAnalytics.debug('Current Date:',function(){
194
+ console.log(year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds);
195
+ });
196
+ var datetime = year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds;
197
+ return datetime;
198
+ },
199
+ /* Set Expiration Date of Session Logging */
200
+ SetSessionTimeout: function(){
201
+ var session_check = this.readCookie("lead_session_expire");
202
+ //console.log(session_check);
203
+ if(session_check === null){
204
+ InboundAnalytics.Events.sessionStart(); // trigger 'inbound_analytics_session_start'
205
+ } else {
206
+ InboundAnalytics.Events.sessionActive(); // trigger 'inbound_analytics_session_active'
207
+ }
208
+ var d = new Date();
209
+ d.setTime(d.getTime() + 30*60*1000);
210
+
211
+ this.createCookie("lead_session_expire", true, d, true); // Set cookie on page loads
212
+ var lead_data_expiration = this.readCookie("lead_data_expiration");
213
+ if (lead_data_expiration === null){
214
+ /* Set 3 day timeout for checking DB for new lead data for Lead_Global var */
215
+ var ex = this.addDays(d, 3);
216
+ this.createCookie("lead_data_expiration", ex, ex, true);
217
+ }
218
+
219
+ },
220
+ getReferer: function(){
221
+ //console.log(expire_time);
222
+ var d = new Date();
223
+ d.setTime(d.getTime() + 30*60*1000);
224
+ var referrer_cookie = InboundAnalytics.Utils.readCookie("wp_lead_referral_site");
225
+ if (typeof (referrer_cookie) === "undefined" || referrer_cookie === null || referrer_cookie === "") {
226
+ var referrer = document.referrer || "NA";
227
+ this.createCookie("wp_lead_referral_site", referrer, d, true); // Set cookie on page loads
228
+ }
229
+ },
230
+ CreateUID: function(length) {
231
+ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''),
232
+ str = '';
233
+ if (! length) {
234
+ length = Math.floor(Math.random() * chars.length);
235
+ }
236
+ for (var i = 0; i < length; i++) {
237
+ str += chars[Math.floor(Math.random() * chars.length)];
238
+ }
239
+ return str;
240
+ },
241
+ SetUID: function () {
242
+ /* Set Lead UID */
243
+
244
+ if(this.readCookie("wp_lead_uid") === null) {
245
+ var wp_lead_uid = this.CreateUID(35);
246
+ this.createCookie("wp_lead_uid", wp_lead_uid );
247
+ InboundAnalytics.debug('Set UID');
248
+ }
249
+ },
250
+ /* Count number of session visits */
251
+ countProperties: function (obj) {
252
+ var count = 0;
253
+ for(var prop in obj) {
254
+ if(obj.hasOwnProperty(prop))
255
+ ++count;
256
+ }
257
+ return count;
258
+ },
259
+ mergeObjs: function(obj1,obj2){
260
+ var obj3 = {};
261
+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
262
+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
263
+ return obj3;
264
+ },
265
+ hasClass: function(className, el) {
266
+ var hasClass = false;
267
+ if ('classList' in document.documentElement) {
268
+ var hasClass = el.classList.contains(className);
269
+ } else {
270
+ var hasClass = new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className); /* IE Polyfill */
271
+ }
272
+ return hasClass;
273
+ },
274
+ trim: function(s) {
275
+ s = s.replace(/(^\s*)|(\s*$)/gi,"");
276
+ s = s.replace(/[ ]{2,}/gi," ");
277
+ s = s.replace(/\n /,"\n"); return s;
278
+ },
279
+ doAjax: function(data, responseHandler, method, async){
280
+ // Set the variables
281
+ var url = wplft.admin_url || "",
282
+ method = method || "POST",
283
+ async = async || true,
284
+ data = data || null,
285
+ action = data.action;
286
+
287
+ InboundAnalytics.debug('Ajax Processed:',function(){
288
+ console.log('ran ajax action: ' + action);
289
+ });
290
+
291
+ jQuery.ajax({
292
+ type: method,
293
+ url: wplft.admin_url,
294
+ data: data,
295
+ success: responseHandler,
296
+ error: function(MLHttpRequest, textStatus, errorThrown){
297
+ console.log(MLHttpRequest+' '+errorThrown+' '+textStatus);
298
+ InboundAnalytics.Events.analyticsError(MLHttpRequest, textStatus, errorThrown);
299
+ }
300
+
301
+ });
302
+ },
303
+ makeRequest: function(url) {
304
+ if (window.XMLHttpRequest) { // Mozilla, Safari, ...
305
+ httpRequest = new XMLHttpRequest();
306
+ } else if (window.ActiveXObject) { // IE
307
+ try {
308
+ httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
309
+ }
310
+ catch (e) {
311
+ try {
312
+ httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
313
+ }
314
+ catch (e) {}
315
+ }
316
+ }
317
+
318
+ if (!httpRequest) {
319
+ alert('Giving up :( Cannot create an XMLHTTP instance');
320
+ return false;
321
+ }
322
+ httpRequest.onreadystatechange = InboundAnalytics.LeadsAPI.alertContents;
323
+ httpRequest.open('GET', url);
324
+ httpRequest.send();
325
+ },
326
+ contentLoaded: function(win, fn) {
327
+
328
+ var done = false, top = true,
329
+
330
+ doc = win.document, root = doc.documentElement,
331
+
332
+ add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
333
+ rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
334
+ pre = doc.addEventListener ? '' : 'on',
335
+
336
+ init = function(e) {
337
+ if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
338
+ (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
339
+ if (!done && (done = true)) fn.call(win, e.type || e);
340
+ },
341
+
342
+ poll = function() {
343
+ try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
344
+ init('poll');
345
+ };
346
+
347
+ if (doc.readyState == 'complete') fn.call(win, 'lazy');
348
+ else {
349
+ if (doc.createEventObject && root.doScroll) {
350
+ try { top = !win.frameElement; } catch(e) { }
351
+ if (top) poll();
352
+ }
353
+ doc[add](pre + 'DOMContentLoaded', init, false);
354
+ doc[add](pre + 'readystatechange', init, false);
355
+ win[add](pre + 'load', init, false);
356
+ }
357
+
358
+ },
359
+ /* Cross-browser event listening */
360
+ addListener: function(obj, eventName, listener) {
361
+ if(obj.addEventListener) {
362
+ obj.addEventListener(eventName, listener, false);
363
+ } else if (obj.attachEvent) {
364
+ obj.attachEvent("on" + eventName, listener);
365
+ } else {
366
+ obj['on' + eventName] = listener;
367
+ }
368
+ }
369
+
370
+ };
371
+
372
+ return InboundAnalytics;
373
+
374
  })(InboundAnalytics || {});
shared/assets/frontend/js/analytics-src/form-mapping.js ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var form = window.document.forms[0];
2
+ var inputsObject = {};
3
+ var rawParams = [];
4
+ var mappedParams = [];
5
+ var getInputValue = function(input) {
6
+ var value = false;
7
+
8
+ switch (input.type) {
9
+ case 'radio':
10
+ case 'checkbox':
11
+ if (input.checked) {
12
+ value = input.value;
13
+ }
14
+ break;
15
+
16
+ case 'text':
17
+ case 'hidden':
18
+ default:
19
+ value = input.value;
20
+ break;
21
+
22
+ }
23
+
24
+ return value;
25
+
26
+ };
27
+ var trim = function(s) {
28
+ s = s.replace(/(^\s*)|(\s*$)/gi,"");
29
+ s = s.replace(/[ ]{2,}/gi," ");
30
+ s = s.replace(/\n /,"\n"); return s;
31
+ };
32
+
33
+ var serialize = function(obj, prefix) {
34
+ var str = [];
35
+ for(var p in obj) {
36
+ if (obj.hasOwnProperty(p)) {
37
+ var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
38
+ str.push(typeof v == "object" ?
39
+ serialize(v, k) :
40
+ encodeURIComponent(k) + "=" + encodeURIComponent(v));
41
+ }
42
+ }
43
+ return str.join("&");
44
+ }
45
+
46
+ var ClosestLabel = function(element, tagname) {
47
+ if(element.nodeName === 'FORM') { return null; }
48
+
49
+ tagname = tagname.toLowerCase();
50
+ do {
51
+ if(element.nodeName.toLowerCase() === tagname){
52
+ var LabelExists = element.getElementsByTagName("label").length>0;
53
+ var labelText = (LabelExists ? element.getElementsByTagName("label")[0].innerText : false);
54
+ return labelText;
55
+ }
56
+
57
+ } while(element = element.parentNode);
58
+
59
+ return null;
60
+ };
61
+ var Closest = function(element, tagname) {
62
+ if(element.nodeName === 'FORM') { return null; }
63
+
64
+ tagname = tagname.toLowerCase();
65
+ do {
66
+ if(element.nodeName.toLowerCase() === tagname){
67
+ return element;
68
+ }
69
+
70
+ } while(element = element.parentNode);
71
+
72
+ return null;
73
+ };
74
+ /* make visible inputs first in loop */
75
+ var sortInputs = function(obj) {
76
+ var visibleInputs = [],
77
+ hiddenInputs = [],
78
+ temp_obj = {};
79
+
80
+ for (var key in obj) {
81
+ if (obj.hasOwnProperty(key)) {
82
+ if(obj[key].type !== "hidden"){
83
+ visibleInputs.push(key);
84
+ } else {
85
+ hiddenInputs.push(key);
86
+ }
87
+ }
88
+ }
89
+
90
+ var merged = hiddenInputs.concat(visibleInputs.reverse()); // Merges both arrays
91
+ for (var i = merged.length - 1; i >= 0; i--) {
92
+ temp_obj[merged[i]] = obj[merged[i]];
93
+ };
94
+
95
+ return temp_obj;
96
+ };
97
+ //var inbound_data = MapInput( this_input );
98
+ inbound_data = {};
99
+ no_match = [];
100
+ var MapInput = function (inputObject) {
101
+
102
+ var matchArray = [ "name",
103
+ "first name",
104
+ "last name",
105
+ "email",
106
+ "e-mail",
107
+ "phone",
108
+ "website",
109
+ "job title",
110
+ "your_favorite_food_",
111
+ "company",
112
+ "tele",
113
+ "address",
114
+ "comment"];
115
+ //var body = jQuery("body");
116
+ var input_id = inputObject.id || false;
117
+ var input_name = inputObject.name || false;
118
+ var this_val = inputObject['value'];
119
+ var input = inputObject['input'];
120
+ // Main Loop
121
+ for (var i = matchArray.length - 1; i >= 0; i--) {
122
+
123
+ var match = matchArray[i];
124
+ //console.log("Match name " + match);
125
+ //console.log("Input name " + input_name);
126
+ var lookingFor = trim(match);
127
+ var nice_name = lookingFor.replace(" ",'_');
128
+ var in_object_already = nice_name in inbound_data;
129
+ console.log('looking for: ' + lookingFor);
130
+
131
+ if (input_name && input_name.toLowerCase().indexOf(lookingFor)>-1) {
132
+ // Look for attr name match
133
+
134
+ console.warn('match name: ' + lookingFor);
135
+ if (!in_object_already) {
136
+ inbound_data[nice_name] = this_val;
137
+ }
138
+ //inbound_data.push('match name: ' + lookingFor + ":" + this_val);
139
+
140
+ } else if (input_id && input_id.toLowerCase().indexOf(lookingFor)>-1) {
141
+ // look for id match
142
+ console.warn("input labels found in form");
143
+ console.log('match id: ' + lookingFor);
144
+ if (!in_object_already) {
145
+ inbound_data[nice_name] = this_val;
146
+ }
147
+ //inbound_data.push('match id: ' + lookingFor + ":" + this_val);
148
+
149
+ } else if (labelText = ClosestLabel(input, "li")) {
150
+ console.warn("li labels found in form");
151
+ if (labelText.toLowerCase().indexOf(lookingFor)>-1) {
152
+ console.log('match label text: ' + lookingFor);
153
+ if (!in_object_already) {
154
+ inbound_data[nice_name] = this_val;
155
+ }
156
+ }
157
+ } else if (labelText = ClosestLabel(input, "div")) {
158
+ console.warn("div labels found in form");
159
+ if (labelText.toLowerCase().indexOf(lookingFor)>-1) {
160
+ console.log('match label text: ' + lookingFor);
161
+ if (!in_object_already) {
162
+ inbound_data[nice_name] = this_val;
163
+ }
164
+ }
165
+
166
+ } else if (labelText = ClosestLabel(input, "p")) {
167
+ console.warn("P labels found in form");
168
+ if (labelText.toLowerCase().indexOf(lookingFor)>-1) {
169
+ console.log('match label text: ' + lookingFor);
170
+ if (!in_object_already) {
171
+ inbound_data[nice_name] = this_val;
172
+ }
173
+ }
174
+
175
+ } else {
176
+ console.warn("No matches");
177
+
178
+ console.log('Need additional mapping data');
179
+ no_match.push(lookingFor + ":" + this_val);
180
+
181
+ }
182
+ }
183
+
184
+ console.log(inbound_data);
185
+ console.log(serialize(inbound_data));
186
+ console.log('no match here', no_match);
187
+ return inbound_data;
188
+
189
+ };
190
+
191
+ for (var i=0; i < form.elements.length; i++) {
192
+
193
+ formInput = form.elements[i];
194
+ multiple = false;
195
+ var parent = formInput.parentNode;
196
+ var parent_parent = parent.parentNode;
197
+ console.log("PARENT", parent);
198
+ console.log("PARENT PARENT", parent_parent);
199
+
200
+ if (formInput.name) {
201
+
202
+ inputName = formInput.name.replace(/\[([^\[]*)\]/g, "_$1");
203
+ inputName = inputName.replace(/-/g, "_");
204
+ if (!inputsObject[inputName]) { inputsObject[inputName] = {}; }
205
+ if (!inputsObject[inputName]['input']) { inputsObject[inputName]['input'] = formInput; };
206
+
207
+ switch (formInput.nodeName) {
208
+
209
+ case 'INPUT':
210
+ value = this.getInputValue(formInput);
211
+
212
+ console.log(value);
213
+ if (value === false) { continue; }
214
+ break;
215
+
216
+ case 'TEXTAREA':
217
+ value = formInput.value;
218
+ break;
219
+
220
+ case 'SELECT':
221
+ if (formInput.multiple) {
222
+ values = [];
223
+ multiple = true;
224
+
225
+ for (var j = 0; j < formInput.length; j++) {
226
+ if (formInput[j].selected) {
227
+ values.push(encodeURIComponent(formInput[j].value));
228
+ }
229
+ }
230
+
231
+ } else {
232
+ value = (formInput.value);
233
+ }
234
+
235
+ console.log('select val', value);
236
+ break;
237
+
238
+ }
239
+
240
+
241
+ if (value) {
242
+
243
+ if (formInput.type) { inputsObject[inputName]['type'] = formInput.type; }
244
+ if (formInput.id) { inputsObject[inputName]['id'] = formInput.id; }
245
+ if ('classList' in document.documentElement) {
246
+ if (formInput.classList) { inputsObject[inputName]['class'] = formInput.classList; }
247
+ }
248
+ // inputsObject[inputName].push(multiple ? values.join(',') : encodeURIComponent(value));
249
+
250
+ if (!inputsObject[inputName]['value']) { inputsObject[inputName]['value'] = []; }
251
+ if (!inputsObject[inputName]['name']) { inputsObject[inputName]['name'] = inputName; }
252
+
253
+ inputsObject[inputName]['value'].push(multiple ? values.join(',') : encodeURIComponent(value));
254
+
255
+ }
256
+
257
+ }
258
+
259
+ }
260
+ console.log(inputsObject);
261
+
262
+
263
+ var inputsObject = sortInputs(inputsObject);
264
+
265
+ var matchCommon = /name|first name|last name|email|e-mail|phone|website|job title|company|tele|address|comment/;
266
+ for (var input in inputsObject) {
267
+ console.log(input);
268
+
269
+ var inputValue = inputsObject[input]['value'];
270
+
271
+ //if (matchCommon.test(input) !== false) {
272
+ console.log(input + " Matches Regex run mapping test");
273
+ var map = MapInput(inputsObject[input]);
274
+ console.log("MAPP", map);
275
+ //mappedParams.push( input + '=' + inputsObject[input]['value'].join(',') );
276
+ //}
277
+
278
+ /* Add custom hook here to look for additional values */
279
+ if (typeof (inputValue) != "undefined" && inputValue != null && inputValue != "") {
280
+ rawParams.push( input + '=' + inputsObject[input]['value'].join(',') );
281
+ }
282
+ }
283
+ var raw_params = rawParams.join('&');
284
+ console.log("Raw PARAMS", raw_params);
285
+ /* Filter here for raw */
286
+ var mapped_params = JSON.stringify(map);
287
+ console.log("Mapped PARAMS", mapped_params);
288
+ /* Filter here for mapped */
shared/assets/frontend/js/analytics/inboundAnalytics.js CHANGED
@@ -1,817 +1,1408 @@
1
- /*! cta v1.0.0 | (c) 2014 Inbound Now | https://github.com/inboundnow/cta */
2
- /**
3
- * Lead Tracking JS
4
- * http://www.inboundnow.com
5
- * This is the main analytics entry point
6
- */
7
- var inbound_data = inbound_data || {};
8
- // Ensure global _gaq Google Analytics queue has been initialized.
9
- var _gaq = _gaq || [];
10
- var InboundAnalytics = (function () {
11
-
12
- var debugMode = false;
13
-
14
- var _privateMethod = function () {
15
- console.log('Run private');
16
- };
17
-
18
- var App = {
19
- init: function () {
20
- InboundAnalytics.Utils.init();
21
- InboundAnalytics.PageTracking.StorePageView();
22
- InboundAnalytics.Events.loadEvents();
23
- },
24
- /* Debugger Function toggled by var debugMode */
25
- debug: function(msg,callback){
26
- //if app not in debug mode, exit immediately
27
- if(!debugMode || !console){return};
28
- var msg = msg || false;
29
- //console.log the message
30
- if(msg && (typeof msg === 'string')){console.log(msg)};
31
-
32
- //execute the callback if one was passed-in
33
- if(callback && (callback instanceof Function)){
34
- callback();
35
- };
36
- }
37
- };
38
-
39
- return App;
40
-
41
- })();
42
- /* Fork of jquery.total-storage.js */
43
- var InboundTotalStorage = (function (InboundAnalytics){
44
-
45
- /* Variables I'll need throghout */
46
-
47
- var supported, ls, mod = 'inboundAnalytics';
48
- if ('localStorage' in window){
49
- try {
50
- ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
51
- if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
52
- supported = false;
53
- } else {
54
- supported = true;
55
- }
56
- window.localStorage.setItem(mod, '1');
57
- window.localStorage.removeItem(mod);
58
- }
59
- catch (err){
60
- supported = false;
61
- }
62
- }
63
-
64
- /* Make the methods public */
65
- InboundAnalytics.totalStorage = function(key, value, options){
66
- return InboundAnalytics.totalStorage.impl.init(key, value);
67
- };
68
-
69
- InboundAnalytics.totalStorage.setItem = function(key, value){
70
- return InboundAnalytics.totalStorage.impl.setItem(key, value);
71
- };
72
-
73
- InboundAnalytics.totalStorage.getItem = function(key){
74
- return InboundAnalytics.totalStorage.impl.getItem(key);
75
- };
76
-
77
- InboundAnalytics.totalStorage.getAll = function(){
78
- return InboundAnalytics.totalStorage.impl.getAll();
79
- };
80
-
81
- InboundAnalytics.totalStorage.deleteItem = function(key){
82
- return InboundAnalytics.totalStorage.impl.deleteItem(key);
83
- };
84
-
85
- /* Object to hold all methods: public and private */
86
-
87
- InboundAnalytics.totalStorage.impl = {
88
-
89
- init: function(key, value){
90
- if (typeof value != 'undefined') {
91
- return this.setItem(key, value);
92
- } else {
93
- return this.getItem(key);
94
- }
95
- },
96
-
97
- setItem: function(key, value){
98
- if (!supported){
99
- try {
100
- InboundAnalytics.Utils.createCookie(key, value);
101
- return value;
102
- } catch(e){
103
- console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');
104
- }
105
- }
106
- var saver = JSON.stringify(value);
107
- ls.setItem(key, saver);
108
- return this.parseResult(saver);
109
- },
110
- getItem: function(key){
111
- if (!supported){
112
- try {
113
- return this.parseResult(InboundAnalytics.Utils.readCookie(key));
114
- } catch(e){
115
- return null;
116
- }
117
- }
118
- var item = ls.getItem(key);
119
- return this.parseResult(item);
120
- },
121
- deleteItem: function(key){
122
- if (!supported){
123
- try {
124
- InboundAnalytics.Utils.eraseCookie(key, null);
125
- return true;
126
- } catch(e){
127
- return false;
128
- }
129
- }
130
- ls.removeItem(key);
131
- return true;
132
- },
133
- getAll: function(){
134
- var items = [];
135
- if (!supported){
136
- try {
137
- var pairs = document.cookie.split(";");
138
- for (var i = 0; i<pairs.length; i++){
139
- var pair = pairs[i].split('=');
140
- var key = pair[0];
141
- items.push({key:key, value:this.parseResult(InboundAnalytics.Utils.readCookie(key))});
142
- }
143
- } catch(e){
144
- return null;
145
- }
146
- } else {
147
- for (var j in ls){
148
- if (j.length){
149
- items.push({key:j, value:this.parseResult(ls.getItem(j))});
150
- }
151
- }
152
- }
153
- return items;
154
- },
155
- parseResult: function(res){
156
- var ret;
157
- try {
158
- ret = JSON.parse(res);
159
- if (typeof ret == 'undefined'){
160
- ret = res;
161
- }
162
- if (ret == 'true'){
163
- ret = true;
164
- }
165
- if (ret == 'false'){
166
- ret = false;
167
- }
168
- if (parseFloat(ret) == ret && typeof ret != "object"){
169
- ret = parseFloat(ret);
170
- }
171
- } catch(e){
172
- ret = res;
173
- }
174
- return ret;
175
- }
176
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  })(InboundAnalytics || {});
178
- /**
179
- * Leads API functions
180
- * @param Object InboundAnalytics - Main JS object
181
- * @return Object - include event triggers
182
- */
183
- var InboundAnalyticsLeadsAPI = (function (InboundAnalytics) {
184
- var httpRequest;
185
- InboundAnalytics.LeadsAPI = {
186
- init: function() {
187
-
188
- },
189
- storeLeadData: function(){
190
- if(element.addEventListener) {
191
- element.addEventListener("submit", function(evt){
192
- evt.preventDefault();
193
- window.history.back();
194
- }, true);
195
- } else {
196
- element.attachEvent('onsubmit', function(evt){
197
- evt.preventDefault();
198
- window.history.back();
199
- });
200
- }
201
- },
202
- attachFormSubmitEvent: function (){
203
- for(var i=0; i<window.document.forms.length; i++){
204
- var form = window.document.forms[i];
205
- var className = "wpl-track-me";
206
- if ('classList' in document.documentElement) {
207
- var hasClass = form.classList.contains(className);
208
- } else {
209
- var hasClass = new RegExp('(^|\\s)' + className + '(\\s|$)').test(form.className); /* IE Polyfill */
210
- }
211
- /* is tracked form */
212
- if(hasClass){
213
- console.log("Has Class", hasClass);
214
- InboundAnalytics.Utils.addListener(form, 'submit', InboundAnalytics.LeadsAPI.formSubmit );
215
- console.log(form);
216
- }
217
-
218
- }
219
- console.log("RAN attach event");
220
- },
221
- makeRequest: function(url) {
222
- if (window.XMLHttpRequest) { // Mozilla, Safari, ...
223
- httpRequest = new XMLHttpRequest();
224
- } else if (window.ActiveXObject) { // IE
225
- try {
226
- httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
227
- }
228
- catch (e) {
229
- try {
230
- httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
231
- }
232
- catch (e) {}
233
- }
234
- }
235
-
236
- if (!httpRequest) {
237
- alert('Giving up :( Cannot create an XMLHTTP instance');
238
- return false;
239
- }
240
- httpRequest.onreadystatechange = InboundAnalytics.LeadsAPI.alertContents;
241
- httpRequest.open('GET', url);
242
- httpRequest.send();
243
- },
244
- inbound_map_fields: function (el, value, Obj) {
245
- var formObj = [];
246
- var $this = el;
247
- var clean_output = value;
248
- var label = $this.closest('label').text();
249
- var exclude = ['credit-card']; // exlcude values from formObj
250
- var inarray = jQuery.inArray(clean_output, exclude);
251
- if(inarray == 0){
252
- return null;
253
- }
254
- // Add items to formObj
255
- formObj.push({
256
- field_label: label,
257
- field_name: $this.attr("name"),
258
- field_value: $this.attr("value"),
259
- field_id: $this.attr("id"),
260
- field_class: $this.attr("class"),
261
- field_type: $this.attr("type"),
262
- match: clean_output,
263
- js_selector: $this.attr("data-js-selector")
264
- });
265
- return formObj;
266
- },
267
- run_field_map_function: function (el, lookingfor) {
268
- var return_form;
269
- var formObj = new Array();
270
- var $this = el;
271
- var body = jQuery("body");
272
- var input_id = $this.attr("id") || "NULL";
273
- var input_name = $this.attr("name") || "NULL";
274
- var this_val = $this.attr("value");
275
- var array = lookingfor.split(",");
276
- var array_length = array.length - 1;
277
-
278
- // Main Loop
279
- for (var i = 0; i < array.length; i++) {
280
- var clean_output = InboundAnalytics.Utils.trim(array[i]);
281
- var nice_name = clean_output.replace(/^\s+|\s+$/g,'');
282
- var nice_name = nice_name.replace(" ",'_');
283
- var in_object_already = nice_name in inbound_data;
284
- //console.log(clean_output);
285
-
286
- if (input_name.toLowerCase().indexOf(clean_output)>-1) {
287
- /* Look for attr name match */
288
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
289
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
290
- console.log('match name: ' + clean_output);
291
- console.log(nice_name in inbound_data);
292
- if (!in_object_already) {
293
- inbound_data[nice_name] = this_val;
294
- }
295
- } else if (input_id.toLowerCase().indexOf(clean_output)>-1) {
296
- /* look for id match */
297
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
298
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
299
- console.log('match id: ' + clean_output);
300
-
301
- if (!in_object_already) {
302
- inbound_data[nice_name] = this_val;
303
- }
304
-
305
- } else if ($this.closest('li').children('label').length>0) {
306
- /* Look for label name match */
307
- var closest_label = $this.closest('li').children('label').html() || "NULL";
308
- if (closest_label.toLowerCase().indexOf(clean_output)>-1) {
309
-
310
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
311
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
312
- console.log($this.context);
313
-
314
- var exists_in_dom = body.find("[data-inbound-form-map='inbound_map_" + nice_name + "']").length;
315
- console.log(exists_in_dom);
316
- console.log('match li: ' + clean_output);
317
-
318
- if (!in_object_already) {
319
- inbound_data[nice_name] = this_val;
320
- }
321
-
322
- }
323
- } else if ($this.closest('div').children('label').length>0) {
324
- /* Look for closest div label name match */
325
- var closest_div = $this.closest('div').children('label').html() || "NULL";
326
- if (closest_div.toLowerCase().indexOf(clean_output)>-1)
327
- {
328
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
329
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
330
- console.log('match div: ' + clean_output);
331
- if (!in_object_already) {
332
- inbound_data[nice_name] = this_val;
333
- }
334
- }
335
- } else if ($this.closest('p').children('label').length>0) {
336
- /* Look for closest p label name match */
337
- var closest_p = $this.closest('p').children('label').html() || "NULL";
338
- if (closest_p.toLowerCase().indexOf(clean_output)>-1)
339
- {
340
- var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
341
- InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
342
- console.log('match p: ' + clean_output);
343
- if (!in_object_already) {
344
- inbound_data[nice_name] = this_val;
345
- }
346
- }
347
- } else {
348
- console.log('Need additional mapping data');
349
- }
350
- }
351
- return_form = the_map;
352
-
353
- return inbound_data;
354
- },
355
- add_inbound_form_class: function(el, value) {
356
- var value = value.replace(" ", "_");
357
- var value = value.replace("-", "_");
358
- el.addClass('inbound_map_value');
359
- el.attr('data-inbound-form-map', 'inbound_map_' + value);
360
- },
361
- inbound_form_type: function(this_form) {
362
- var inbound_data = inbound_data || {},
363
- form_type = 'normal';
364
- if ( this_form.is( ".wpl-comment-form" ) ) {
365
- inbound_data['form_type'] = 'comment';
366
- form_type = 'comment';
367
- } else if ( this_form.is( ".wpl-search-box" ) ) {
368
- var is_search = true;
369
- form_type = 'search';
370
- inbound_data['form_type'] = 'search';
371
- } else if ( this_form.is( '.wpl-track-me-link' ) ){
372
- var have_email = readCookie('wp_lead_email');
373
- console.log(have_email);
374
- inbound_data['form_type'] = 'link';
375
- form_type = 'search';
376
- }
377
- return form_type;
378
- },
379
- grab_all_form_input_vals: function(this_form){
380
- var post_values = post_values || {},
381
- inbound_exclude = inbound_exclude || [],
382
- form_inputs = this_form.find('input,textarea,select');
383
- inbound_exclude.push('inbound_furl', 'inbound_current_page_url', 'inbound_notify', 'inbound_submitted', 'post_type', 'post_status', 's', 'inbound_form_name', 'inbound_form_id', 'inbound_form_lists');
384
- var form_type = InboundAnalytics.LeadsAPI.inbound_form_type(this_form),
385
- inbound_data = inbound_data || {},
386
- email = inbound_data['email'] || false;
387
-
388
- form_inputs.each(function() {
389
- var $input = jQuery(this),
390
- input_type = $input.attr('type'),
391
- input_val = $input.val();
392
- if (input_type === 'checkbox') {
393
- input_checked = $input.attr("checked");
394
- console.log(input_val);
395
- console.log(input_checked);
396
- console.log(post_values[this.name]);
397
- if (input_checked === "checked"){
398
- if (typeof (post_values[this.name]) != "undefined") {
399
- post_values[this.name] = post_values[this.name] + "," + input_val;
400
- console.log(post_values[this.name]);
401
- } else {
402
- post_values[this.name] = input_val;
403
- }
404
-
405
- }
406
- }
407
- if (jQuery.inArray(this.name, inbound_exclude) === -1 && input_type != 'checkbox'){
408
- post_values[this.name] = input_val;
409
- }
410
- if (this.value.indexOf('@')>-1&&!email){
411
- email = input_val;
412
- inbound_data['email'] = email;
413
- }
414
- if (form_type === 'search') {
415
- inbound_data['search_keyword'] = input_val.replace('"', "'");
416
- }
417
- });
418
- var all_form_fields = JSON.stringify(post_values);
419
- return all_form_fields;
420
- },
421
- return_mapped_values: function (this_form) {
422
- // Map form fields
423
- jQuery(this_form).find('input[type!="hidden"],textarea,select').each(function() {
424
- console.log('run');
425
- var this_input = jQuery(this);
426
- var this_input_val = this_input.val();
427
- if (typeof (this_input_val) != "undefined" && this_input_val != null && this_input_val != "") {
428
- var inbound_data = InboundAnalytics.LeadsAPI.run_field_map_function( this_input, "name, first name, last name, email, e-mail, phone, website, job title, company, tele, address, comment");
429
- }
430
- return inbound_data;
431
- });
432
- return inbound_data;
433
- },
434
- inbound_form_submit: function(this_form, e) {
435
- /* Define Variables */
436
- var data = inbound_data || {};
437
- // Dynamic JS object for passing custom values. This can be hooked into by third parties by using the below syntax.
438
- var pageviewObj = jQuery.totalStorage('page_views');
439
- data['page_view_count'] = InboundAnalytics.Utils.countProperties(pageviewObj);
440
- data['leads_list'] = jQuery(this_form).find('#inbound_form_lists').val();
441
- data['source'] = jQuery.cookie("wp_lead_referral_site") || "NA";
442
- data['page_id'] = inbound_ajax.post_id;
443
- data['page_views'] = JSON.stringify(pageviewObj);
444
-
445
- // Map form fields
446
- var returned_form_data = InboundAnalytics.LeadsAPI.return_mapped_values(this_form); //console.log(returned_form_data);
447
- var data = InboundAnalytics.Utils.mergeObjs(data,returned_form_data); //console.log(data);
448
- var this_form = jQuery(this_form);
449
- // Set variables after mapping
450
- data['email'] = (!data['email']) ? this_form.find('.inbound-email').val() : data['email'];
451
- data['form_name'] = this_form.find('.inbound_form_name').val() || "Not Found";
452
- data['form_id'] = this_form.find('.inbound_form_id').val() || "Not Found";
453
- data['first_name'] = (!data['first_name']) ? data['name'] : data['first_name'];
454
- data['last_name'] = data['last_name'] || '';
455
- data['phone'] = data['phone'] || '';
456
- data['company'] = data['company'] || '';
457
- data['address'] = data['address'] || '';
458
-
459
- // Fallbacks for values
460
- data['name'] = (data['first_name'] && data['last_name']) ? data['first_name'] + " " + data['last_name'] : data['name'];
461
-
462
- if (!data['last_name'] && data['first_name']) {
463
- var parts = data['first_name'].split(" ");
464
- data['first_name'] = parts[0];
465
- data['last_name'] = parts[1];
466
- }
467
-
468
- /* Store form fields & exclude field values */
469
- var all_form_fields = InboundAnalytics.LeadsAPI.grab_all_form_input_vals(this_form);
470
- /* end Store form fields & exclude field values */
471
-
472
- if(data['email']){
473
- InboundAnalytics.Utils.createCookie("wp_lead_email", data['email'], 365); /* set email cookie */
474
- }
475
-
476
- //var variation = (typeof (landing_path_info) != "undefined") ? landing_path_info.variation : false;
477
-
478
- if (typeof (landing_path_info) != "undefined") {
479
- var variation = landing_path_info.variation;
480
- } else if (typeof (cta_path_info) != "undefined") {
481
- var variation = cta_path_info.variation;
482
- } else {
483
- var variation = 0;
484
- }
485
-
486
- data['variation'] = variation;
487
- data['post_type'] = inbound_ajax.post_type;
488
- data['wp_lead_uid'] = jQuery.cookie("wp_lead_uid") || null;
489
- data['ip_address'] = inbound_ajax.ip_address;
490
- data['search_data'] = JSON.stringify(jQuery.totalStorage('inbound_search')) || {};
491
-
492
- var lp_check = (inbound_ajax.post_type === 'landing-page') ? 'Landing Page' : "";
493
- var cta_check = (inbound_ajax.post_type === 'wp-call-to-action') ? 'Call to Action' : "";
494
- var page_type = (!cta_check && !lp_check) ? inbound_ajax.post_type : lp_check + cta_check;
495
-
496
- // jsonify data
497
- var mapped_form_data = JSON.stringify(data);
498
-
499
- var return_data = {};
500
- var return_data = {
501
- "action": 'inbound_store_lead',
502
- "emailTo": data['email'],
503
- "first_name": data['first_name'],
504
- "last_name": data['last_name'],
505
- "phone": data['phone'],
506
- "address": data['address'],
507
- "company_name": data['company'],
508
- "page_views": data['page_views'],
509
- "form_input_values": all_form_fields,
510
- "Mapped_Data": mapped_form_data,
511
- "Search_Data": data['search_data']
512
- }
513
- return return_data;
514
- },
515
- formSubmit: function (e){
516
- /*if(!confirm('Are you sure?')) {
517
- e.returnValue = false;
518
- if(e.preventDefault) e.preventDefault();
519
- return false;
520
- }
521
- return true;*/
522
- /*var inbound_data = inbound_data || {},
523
- this_form = e.target,
524
- event_type = e.type,
525
- is_search = false,
526
- form_type = 'normal';*/
527
-
528
- e.preventDefault(); /* Halt form processing */
529
- console.log("This works");
530
- var data = InboundAnalytics.LeadsAPI.inbound_form_submit(e.target, e); // big function for processing
531
- console.log(data);
532
- alert('Working');
533
- //document.getElementById("ajaxButton").onclick = function() { makeRequest('test.html'); };
534
-
535
- /* Final Ajax Call on Submit */
536
- InboundAnalytics.LeadsAPI.makeRequest('test.html');
537
- },
538
- alertContents: function() {
539
- if (httpRequest.readyState === 4) {
540
- if (httpRequest.status === 200) {
541
- alert(httpRequest.responseText);
542
- } else if(xmlhttp.status == 400) {
543
- alert('There was an error 400');
544
- } else {
545
- alert('There was a problem with the request.');
546
- }
547
- }
548
- },
549
- getAllLeadData: function(expire_check) {
550
- var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id"),
551
- old_data = jQuery.totalStorage('inbound_lead_data'),
552
- data = {
553
- action: 'inbound_get_all_lead_data',
554
- wp_lead_id: wp_lead_id,
555
- },
556
- success = function(returnData){
557
- var obj = JSON.parse(returnData);
558
- console.log('RAAAAAAn');
559
- setGlobalLeadVar(obj);
560
- jQuery.totalStorage('inbound_lead_data', obj); // store lead data
561
- };
562
-
563
- if(!old_data) {
564
- console.log("No old data");
565
- }
566
-
567
- if (expire_check === 'true'){
568
- console.log("Session has not expired");
569
- }
570
-
571
- if(!old_data && expire_check === null) {
572
- InboundAnalytics.debug('Go to Database',function(){
573
- console.log(expire_check);
574
- console.log(old_data);
575
- });
576
- InboundAnalytics.Utils.doAjax(data, success);
577
- } else {
578
- setGlobalLeadVar(old_data); // set global lead var with localstorage data
579
- var lead_data_expiration = InboundAnalytics.Utils.readCookie("lead_data_expiration");
580
- if (lead_data_expiration === null) {
581
- InboundAnalytics.Utils.doAjax(data, success);
582
- console.log('localized data old. Pull new from DB');
583
- }
584
- }
585
-
586
- },
587
- getLeadLists: function() {
588
- var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id");
589
- var data = {
590
- action: 'wpl_check_lists',
591
- wp_lead_id: wp_lead_id,
592
- };
593
- var success = function(user_id){
594
- jQuery.cookie("lead_session_list_check", true, { path: '/', expires: 1 });
595
- console.log("Lists checked");
596
- };
597
- InboundAnalytics.Utils.doAjax(data, success);
598
- }
599
- };
600
-
601
- return InboundAnalytics;
602
-
603
  })(InboundAnalytics || {});
604
- var InboundAnalyticsPageTracking = (function (InboundAnalytics) {
605
-
606
- InboundAnalytics.PageTracking = {
607
-
608
- getPageViews: function () {
609
- var local_store = InboundAnalytics.Utils.checkLocalStorage();
610
- if(local_store){
611
- var page_views = localStorage.getItem("page_views"),
612
- local_object = JSON.parse(page_views);
613
- if (typeof local_object =='object' && local_object) {
614
- this.StorePageView();
615
- }
616
- return local_object;
617
- }
618
- },
619
- StorePageView: function() {
620
- var timeout = this.CheckTimeOut();
621
- var pageviewObj = jQuery.totalStorage('page_views');
622
- if(pageviewObj === null) {
623
- pageviewObj = {};
624
- }
625
- var current_page_id = wplft.post_id;
626
- var datetime = InboundAnalytics.Utils.GetDate();
627
-
628
- if (timeout) {
629
- // If pageviewObj exists, do this
630
- var page_seen = pageviewObj[current_page_id];
631
-
632
- if(typeof(page_seen) != "undefined" && page_seen !== null) {
633
- pageviewObj[current_page_id].push(datetime);
634
- /* Page Revisit Trigger */
635
- var page_seen_count = pageviewObj[current_page_id].length;
636
- InboundAnalytics.Events.pageRevisit(page_seen_count);
637
-
638
- } else {
639
- pageviewObj[current_page_id] = [];
640
- pageviewObj[current_page_id].push(datetime);
641
- /* Page First Seen Trigger */
642
- var page_seen_count = 1;
643
- InboundAnalytics.Events.pageFirstView(page_seen_count);
644
- }
645
-
646
- jQuery.totalStorage('page_views', pageviewObj);
647
-
648
- }
649
- },
650
- CheckTimeOut: function() {
651
- var PageViews = jQuery.totalStorage('page_views');
652
- if(PageViews === null) {
653
- var PageViews = {};
654
- }
655
- var page_id = wplft.post_id,
656
- pageviewTimeout = true, /* Default */
657
- page_seen = PageViews[page_id];
658
- if(typeof(page_seen) != "undefined" && page_seen !== null) {
659
-
660
- var time_now = InboundAnalytics.Utils.GetDate(),
661
- vc = PageViews[page_id].length - 1,
662
- last_view = PageViews[page_id][vc],
663
- last_view_ms = new Date(last_view).getTime(),
664
- time_now_ms = new Date(time_now).getTime(),
665
- timeout_ms = last_view_ms + 30*1000,
666
- time_check = Math.abs(last_view_ms - time_now_ms),
667
- wait_time = 30000;
668
-
669
- InboundAnalytics.debug('Timeout Checks =',function(){
670
- console.log('Current Time is: ' + time_now);
671
- console.log('Last view is: ' + last_view);
672
- console.log("Last view milliseconds " + last_view_ms);
673
- console.log("time now milliseconds " + time_now_ms);
674
- console.log("Wait Check: " + wait_time);
675
- console.log("TIME CHECK: " + time_check);
676
- });
677
-
678
- //var wait_time = Math.abs(last_view_ms - timeout_ms) // output timeout time 30sec;
679
-
680
- if (time_check < wait_time){
681
- time_left = Math.abs((wait_time - time_check)) * .001;
682
- pageviewTimeout = false;
683
- var status = '30 sec timeout not done: ' + time_left + " seconds left";
684
- } else {
685
- var status = 'Timeout Happened. Page view fired';
686
- this.firePageView();
687
- pageviewTimeout = true;
688
- InboundAnalytics.Events.analyticsTriggered();
689
- }
690
-
691
- //InboundAnalytics.debug('',function(){
692
- console.log(status);
693
- //});
694
- } else {
695
- /* Page never seen before */
696
- this.firePageView();
697
- }
698
-
699
- return pageviewTimeout;
700
-
701
- },
702
- firePageView: function() {
703
- var lead_id = InboundAnalytics.Utils.readCookie('wp_lead_id'),
704
- lead_uid = InboundAnalytics.Utils.readCookie('wp_lead_uid');
705
-
706
- if (typeof (lead_id) != "undefined" && lead_id != null && lead_id != "") {
707
-
708
- InboundAnalytics.debug('Run page view ajax');
709
-
710
- var data = {
711
- action: 'wpl_track_user',
712
- wp_lead_uid: lead_uid,
713
- wp_lead_id: lead_id,
714
- page_id: wplft.post_id,
715
- current_url: window.location.href,
716
- json: '0'
717
- };
718
- var firePageCallback = function(user_id){
719
- InboundAnalytics.Events.analyticsSaved();
720
- };
721
- InboundAnalytics.Utils.doAjax(data, firePageCallback);
722
- }
723
- },
724
- tabSwitch: function() {
725
- /* test out simplier script
726
- function onBlur() {
727
- document.body.className = 'blurred';
728
- };
729
- function onFocus(){
730
- document.body.className = 'focused';
731
- };
732
-
733
- if (false) { // check for Internet Explorer
734
- document.onfocusin = onFocus;
735
- document.onfocusout = onBlur;
736
- } else {
737
- window.onfocus = onFocus;
738
- window.onblur = onBlur;
739
- }
740
- */
741
-
742
- var hidden, visibilityState, visibilityChange;
743
-
744
- if (typeof document.hidden !== "undefined") {
745
- hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
746
- } else if (typeof document.mozHidden !== "undefined") {
747
- hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
748
- } else if (typeof document.msHidden !== "undefined") {
749
- hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
750
- } else if (typeof document.webkitHidden !== "undefined") {
751
- hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
752
- } // if
753
-
754
- var document_hidden = document[hidden];
755
-
756
- document.addEventListener(visibilityChange, function() {
757
- if(document_hidden != document[hidden]) {
758
- if(document[hidden]) {
759
- // Document hidden
760
- console.log('hidden');
761
- InboundAnalytics.Events.browserTabHidden();
762
- } else {
763
- // Document shown
764
- console.log('shown');
765
- InboundAnalytics.Events.browserTabVisible();
766
- } // if
767
-
768
- document_hidden = document[hidden];
769
- } // if
770
- });
771
- }
772
- }
773
-
774
- return InboundAnalytics;
775
-
776
  })(InboundAnalytics || {});
777
- /**
778
- * Init Inbound Analytics
779
- * - initializes analytics
780
- */
781
-
782
- var Lead_Globals = jQuery.totalStorage('inbound_lead_data') || null;
783
- function setGlobalLeadVar(retString){
784
- Lead_Globals = retString;
785
- }
786
-
787
- InboundAnalytics.init(); // run analytics
788
-
789
- /* run on ready */
790
- jQuery(document).ready(function($) {
791
- //record non conversion status
792
- var in_u = InboundAnalytics.Utils,
793
- wp_lead_uid = in_u.readCookie("wp_lead_uid"),
794
- wp_lead_id = in_u.readCookie("wp_lead_id"),
795
- expire_check = in_u.readCookie("lead_session_expire"); // check for session
796
-
797
- if (expire_check === null) {
798
- console.log('expired vistor. Run Processes');
799
- //var data_to_lookup = global-localized-vars;
800
- if (typeof (wp_lead_id) != "undefined" && wp_lead_id != null && wp_lead_id != "") {
801
- /* Get Lead_Globals */
802
- InboundAnalytics.LeadsAPI.getAllLeadData(expire_check);
803
- /* Lead list check */
804
- InboundAnalytics.LeadsAPI.getLeadLists();
805
- }
806
- }
807
-
808
- //window.addEventListener('load',function(){
809
- // InboundAnalytics.LeadsAPI.attachSubmitEvent(window,InboundAnalytics.LeadsAPI.formSubmit);
810
- //}, false);
811
-
812
- in_u.contentLoaded(window, InboundAnalytics.LeadsAPI.attachFormSubmitEvent);
813
-
814
- /* Set Session Timeout */
815
- in_u.SetSessionTimeout();
816
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
  });
1
+ /*! Inbound Analyticsv1.0.0 | (c) 2014 Inbound Now | https://github.com/inboundnow/cta */
2
+ /**
3
+ * Lead Tracking JS
4
+ * http://www.inboundnow.com
5
+ * This is the main analytics entry point
6
+ */
7
+ var inbound_data = inbound_data || {};
8
+ var _inboundOptions = _inboundOptions || {};
9
+ /* Ensure global _gaq Google Analytics queue has been initialized. */
10
+ var _gaq = _gaq || [];
11
+
12
+ var InboundAnalytics = (function (Options) {
13
+
14
+ /* Constants */
15
+ var debugMode = false;
16
+
17
+ var App = {
18
+ /* Initialize individual modules */
19
+ init: function () {
20
+ InboundAnalytics.Utils.init();
21
+ InboundAnalytics.PageTracking.StorePageView();
22
+ InboundAnalytics.Events.loadEvents();
23
+ InboundAnalytics.Forms.init();
24
+ },
25
+ /* Debugger Function toggled by var debugMode */
26
+ debug: function(msg, callback){
27
+ //if app not in debug mode, exit immediately
28
+ if(!debugMode || !console){return};
29
+ var msg = msg || false;
30
+ //console.log the message
31
+ if(msg && (typeof msg === 'string')){console.log(msg)};
32
+
33
+ //execute the callback if one was passed-in
34
+ if(callback && (callback instanceof Function)){
35
+ callback();
36
+ };
37
+ }
38
+ };
39
+
40
+ return App;
41
+
42
+ })(_inboundOptions);
43
+ /**
44
+ * Utility functions
45
+ * @param Object InboundAnalytics - Main JS object
46
+ * include util functions
47
+ */
48
+ var InboundAnalyticsUtils = (function (InboundAnalytics) {
49
+
50
+ InboundAnalytics.Utils = {
51
+ init: function() {
52
+ this.polyFills();
53
+ this.setUrlParams();
54
+ this.SetUID();
55
+ this.getReferer();
56
+
57
+ },
58
+ /* Polyfills for missing browser functionality */
59
+ polyFills: function() {
60
+ /* Console.log fix for old browsers */
61
+ if (!window.console) { window.console = {}; }
62
+ var m = [
63
+ "log", "info", "warn", "error", "debug", "trace", "dir", "group",
64
+ "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
65
+ "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
66
+ ];
67
+ // define undefined methods as noops to prevent errors
68
+ for (var i = 0; i < m.length; i++) {
69
+ if (!window.console[m[i]]) {
70
+ window.console[m[i]] = function() {};
71
+ }
72
+ }
73
+ /* Event trigger polyfill for IE9 and 10 */
74
+ (function () {
75
+ function CustomEvent ( event, params ) {
76
+ params = params || { bubbles: false, cancelable: false, detail: undefined };
77
+ var evt = document.createEvent( 'CustomEvent' );
78
+ evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
79
+ return evt;
80
+ };
81
+
82
+ CustomEvent.prototype = window.Event.prototype;
83
+
84
+ window.CustomEvent = CustomEvent;
85
+ })();
86
+ },
87
+ // Create cookie
88
+ createCookie: function(name, value, days, custom_time) {
89
+ var expires = "";
90
+ if (days) {
91
+ var date = new Date();
92
+ date.setTime(date.getTime()+(days*24*60*60*1000));
93
+ expires = "; expires="+date.toGMTString();
94
+ }
95
+ if(custom_time){
96
+ expires = "; expires="+days.toGMTString();
97
+ }
98
+ document.cookie = name+"="+value+expires+"; path=/";
99
+ },
100
+ /* Read cookie */
101
+ readCookie: function(name) {
102
+ var nameEQ = name + "=";
103
+ var ca = document.cookie.split(';');
104
+ for(var i=0;i < ca.length;i++) {
105
+ var c = ca[i];
106
+ while (c.charAt(0) === ' ') {
107
+ c = c.substring(1,c.length);
108
+ }
109
+ if (c.indexOf(nameEQ) === 0) {
110
+ return c.substring(nameEQ.length,c.length);
111
+ }
112
+ }
113
+ return null;
114
+ },
115
+ /* Erase cookies */
116
+ eraseCookie: function(name) {
117
+ createCookie(name,"",-1);
118
+ },
119
+ /* Get All Cookies */
120
+ getAllCookies: function(){
121
+ var cookies = {};
122
+ if (document.cookie && document.cookie != '') {
123
+ var split = document.cookie.split(';');
124
+ for (var i = 0; i < split.length; i++) {
125
+ var name_value = split[i].split("=");
126
+ name_value[0] = name_value[0].replace(/^ /, '');
127
+ cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
128
+ }
129
+ }
130
+ jQuery.totalStorage('inbound_cookies', cookies); // store cookie data
131
+ return cookies;
132
+ },
133
+ /* Grab URL params and save */
134
+ setUrlParams: function() {
135
+ var urlParams = {},
136
+ local_store = this.checkLocalStorage();
137
+
138
+ (function () {
139
+ var e,
140
+ d = function (s) { return decodeURIComponent(s).replace(/\+/g, " "); },
141
+ q = window.location.search.substring(1),
142
+ r = /([^&=]+)=?([^&]*)/g;
143
+
144
+ while (e = r.exec(q)) {
145
+ if (e[1].indexOf("[") == "-1")
146
+ urlParams[d(e[1])] = d(e[2]);
147
+ else {
148
+ var b1 = e[1].indexOf("["),
149
+ aN = e[1].slice(b1+1, e[1].indexOf("]", b1)),
150
+ pN = d(e[1].slice(0, b1));
151
+
152
+ if (typeof urlParams[pN] != "object")
153
+ urlParams[d(pN)] = {},
154
+ urlParams[d(pN)].length = 0;
155
+
156
+ if (aN)
157
+ urlParams[d(pN)][d(aN)] = d(e[2]);
158
+ else
159
+ Array.prototype.push.call(urlParams[d(pN)], d(e[2]));
160
+
161
+ }
162
+ }
163
+ })();
164
+
165
+ if (JSON) {
166
+ for (var k in urlParams) {
167
+ if (typeof urlParams[k] == "object") {
168
+ for (var k2 in urlParams[k])
169
+ this.createCookie(k2, urlParams[k][k2], 30);
170
+ } else {
171
+ this.createCookie(k, urlParams[k], 30);
172
+ }
173
+ }
174
+ }
175
+
176
+ if(local_store){
177
+ var pastParams = jQuery.totalStorage('inbound_url_params');
178
+ var params = this.mergeObjs(pastParams, urlParams);
179
+ jQuery.totalStorage('inbound_url_params', params); // store cookie data
180
+ }
181
+ },
182
+ getUrlParams: function(){
183
+ var local_store = this.checkLocalStorage(),
184
+ get_params = {};
185
+ if(local_store){
186
+ var get_params = jQuery.totalStorage('inbound_url_params');
187
+ }
188
+ return get_params;
189
+ },
190
+ // Check local storage
191
+ // provate browsing safari fix https://github.com/marcuswestin/store.js/issues/42#issuecomment-25274685
192
+ checkLocalStorage: function() {
193
+ if ('localStorage' in window) {
194
+ try {
195
+ ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
196
+ if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
197
+ supported = false;
198
+ } else {
199
+ supported = true;
200
+ }
201
+
202
+ }
203
+ catch (err){
204
+ supported = false;
205
+ }
206
+ }
207
+ return supported;
208
+ /* http://spin.atomicobject.com/2013/01/23/ios-private-browsing-localstorage/
209
+ var hasStorage;
210
+ hasStorage = function() {
211
+ var mod, result;
212
+ try {
213
+ mod = new Date;
214
+ localStorage.setItem(mod, mod.toString());
215
+ result = localStorage.getItem(mod) === mod.toString();
216
+ localStorage.removeItem(mod);
217
+ return result;
218
+ } catch (_error) {}
219
+ };
220
+ */
221
+ },
222
+ /* Add days to datetime */
223
+ addDays: function(myDate,days) {
224
+ return new Date(myDate.getTime() + days*24*60*60*1000);
225
+ },
226
+ GetDate: function(){
227
+ var time_now = new Date(),
228
+ day = time_now.getDate() + 1;
229
+ year = time_now.getFullYear(),
230
+ hour = time_now.getHours(),
231
+ minutes = time_now.getMinutes(),
232
+ seconds = time_now.getSeconds(),
233
+ month = time_now.getMonth() + 1;
234
+ if (month < 10) { month = '0' + month; }
235
+ InboundAnalytics.debug('Current Date:',function(){
236
+ console.log(year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds);
237
+ });
238
+ var datetime = year + '/' + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds;
239
+ return datetime;
240
+ },
241
+ /* Set Expiration Date of Session Logging */
242
+ SetSessionTimeout: function(){
243
+ var session_check = this.readCookie("lead_session_expire");
244
+ //console.log(session_check);
245
+ if(session_check === null){
246
+ InboundAnalytics.Events.sessionStart(); // trigger 'inbound_analytics_session_start'
247
+ } else {
248
+ InboundAnalytics.Events.sessionActive(); // trigger 'inbound_analytics_session_active'
249
+ }
250
+ var d = new Date();
251
+ d.setTime(d.getTime() + 30*60*1000);
252
+
253
+ this.createCookie("lead_session_expire", true, d, true); // Set cookie on page loads
254
+ var lead_data_expiration = this.readCookie("lead_data_expiration");
255
+ if (lead_data_expiration === null){
256
+ /* Set 3 day timeout for checking DB for new lead data for Lead_Global var */
257
+ var ex = this.addDays(d, 3);
258
+ this.createCookie("lead_data_expiration", ex, ex, true);
259
+ }
260
+
261
+ },
262
+ getReferer: function(){
263
+ //console.log(expire_time);
264
+ var d = new Date();
265
+ d.setTime(d.getTime() + 30*60*1000);
266
+ var referrer_cookie = InboundAnalytics.Utils.readCookie("wp_lead_referral_site");
267
+ if (typeof (referrer_cookie) === "undefined" || referrer_cookie === null || referrer_cookie === "") {
268
+ var referrer = document.referrer || "NA";
269
+ this.createCookie("wp_lead_referral_site", referrer, d, true); // Set cookie on page loads
270
+ }
271
+ },
272
+ CreateUID: function(length) {
273
+ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''),
274
+ str = '';
275
+ if (! length) {
276
+ length = Math.floor(Math.random() * chars.length);
277
+ }
278
+ for (var i = 0; i < length; i++) {
279
+ str += chars[Math.floor(Math.random() * chars.length)];
280
+ }
281
+ return str;
282
+ },
283
+ SetUID: function () {
284
+ /* Set Lead UID */
285
+
286
+ if(this.readCookie("wp_lead_uid") === null) {
287
+ var wp_lead_uid = this.CreateUID(35);
288
+ this.createCookie("wp_lead_uid", wp_lead_uid );
289
+ InboundAnalytics.debug('Set UID');
290
+ }
291
+ },
292
+ /* Count number of session visits */
293
+ countProperties: function (obj) {
294
+ var count = 0;
295
+ for(var prop in obj) {
296
+ if(obj.hasOwnProperty(prop))
297
+ ++count;
298
+ }
299
+ return count;
300
+ },
301
+ mergeObjs: function(obj1,obj2){
302
+ var obj3 = {};
303
+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
304
+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
305
+ return obj3;
306
+ },
307
+ hasClass: function(className, el) {
308
+ var hasClass = false;
309
+ if ('classList' in document.documentElement) {
310
+ var hasClass = el.classList.contains(className);
311
+ } else {
312
+ var hasClass = new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className); /* IE Polyfill */
313
+ }
314
+ return hasClass;
315
+ },
316
+ trim: function(s) {
317
+ s = s.replace(/(^\s*)|(\s*$)/gi,"");
318
+ s = s.replace(/[ ]{2,}/gi," ");
319
+ s = s.replace(/\n /,"\n"); return s;
320
+ },
321
+ doAjax: function(data, responseHandler, method, async){
322
+ // Set the variables
323
+ var url = wplft.admin_url || "",
324
+ method = method || "POST",
325
+ async = async || true,
326
+ data = data || null,
327
+ action = data.action;
328
+
329
+ InboundAnalytics.debug('Ajax Processed:',function(){
330
+ console.log('ran ajax action: ' + action);
331
+ });
332
+
333
+ jQuery.ajax({
334
+ type: method,
335
+ url: wplft.admin_url,
336
+ data: data,
337
+ success: responseHandler,
338
+ error: function(MLHttpRequest, textStatus, errorThrown){
339
+ console.log(MLHttpRequest+' '+errorThrown+' '+textStatus);
340
+ InboundAnalytics.Events.analyticsError(MLHttpRequest, textStatus, errorThrown);
341
+ }
342
+
343
+ });
344
+ },
345
+ makeRequest: function(url) {
346
+ if (window.XMLHttpRequest) { // Mozilla, Safari, ...
347
+ httpRequest = new XMLHttpRequest();
348
+ } else if (window.ActiveXObject) { // IE
349
+ try {
350
+ httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
351
+ }
352
+ catch (e) {
353
+ try {
354
+ httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
355
+ }
356
+ catch (e) {}
357
+ }
358
+ }
359
+
360
+ if (!httpRequest) {
361
+ alert('Giving up :( Cannot create an XMLHTTP instance');
362
+ return false;
363
+ }
364
+ httpRequest.onreadystatechange = InboundAnalytics.LeadsAPI.alertContents;
365
+ httpRequest.open('GET', url);
366
+ httpRequest.send();
367
+ },
368
+ contentLoaded: function(win, fn) {
369
+
370
+ var done = false, top = true,
371
+
372
+ doc = win.document, root = doc.documentElement,
373
+
374
+ add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
375
+ rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
376
+ pre = doc.addEventListener ? '' : 'on',
377
+
378
+ init = function(e) {
379
+ if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
380
+ (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
381
+ if (!done && (done = true)) fn.call(win, e.type || e);
382
+ },
383
+
384
+ poll = function() {
385
+ try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
386
+ init('poll');
387
+ };
388
+
389
+ if (doc.readyState == 'complete') fn.call(win, 'lazy');
390
+ else {
391
+ if (doc.createEventObject && root.doScroll) {
392
+ try { top = !win.frameElement; } catch(e) { }
393
+ if (top) poll();
394
+ }
395
+ doc[add](pre + 'DOMContentLoaded', init, false);
396
+ doc[add](pre + 'readystatechange', init, false);
397
+ win[add](pre + 'load', init, false);
398
+ }
399
+
400
+ },
401
+ /* Cross-browser event listening */
402
+ addListener: function(obj, eventName, listener) {
403
+ if(obj.addEventListener) {
404
+ obj.addEventListener(eventName, listener, false);
405
+ } else if (obj.attachEvent) {
406
+ obj.attachEvent("on" + eventName, listener);
407
+ } else {
408
+ obj['on' + eventName] = listener;
409
+ }
410
+ }
411
+
412
+ };
413
+
414
+ return InboundAnalytics;
415
+
416
  })(InboundAnalytics || {});
417
+ /**
418
+ * Form functions
419
+ * @param Object InboundAnalytics - Form tracking functionality
420
+ * @return Object - form functions
421
+ */
422
+ var InboundForms = (function (InboundAnalytics) {
423
+
424
+ InboundAnalytics.Forms = {
425
+ // Init Form functions
426
+ init: function() {
427
+ this.attachFormSubmitEvent();
428
+ },
429
+ formLoop: function(){
430
+ for(var i=0; i<window.document.forms.length; i++){
431
+ var form = window.document.forms[i];
432
+ var trackForm = InboundAnalytics.Utils.hasClass("wpl-track-me", form);
433
+ if (trackForm) {
434
+ this.attachFormSubmitEvent(form); /* attach form listener */
435
+
436
+ }
437
+ }
438
+ },
439
+ formSubmit: function(form) {
440
+
441
+ },
442
+ mapFormValues: function(form) {
443
+ var inputByName = {};
444
+ var params = [];
445
+ /* test for [] array syntax */
446
+ var fieldNameExp = /\[([^\[]*)\]/g;
447
+ for (var i=0; i < form.elements.length; i++) {
448
+
449
+ formField = form.elements[i];
450
+ multiple = false;
451
+
452
+ if (formField.name) {
453
+ /* test for [] array syntax */
454
+ cleanName = formField.name.replace(fieldNameExp, "_$1");
455
+ if (!inputByName[cleanName]) { inputByName[cleanName] = []; }
456
+
457
+ switch (formField.nodeName) {
458
+
459
+ case 'INPUT':
460
+ value = this.getInputValue(formField);
461
+ console.log(value);
462
+ if (value === false) { continue; }
463
+ break;
464
+
465
+ case 'SELECT':
466
+ if (formField.multiple) {
467
+ values = [];
468
+ multiple = true;
469
+
470
+ for (var j = 0; j < formField.length; j++) {
471
+ if (formField[j].selected) {
472
+ values.push(encodeURIComponent(formField[j].value));
473
+ }
474
+ }
475
+
476
+ } else {
477
+ value = (formField.value);
478
+ }
479
+ break;
480
+
481
+ case 'TEXTAREA':
482
+ value = formField.value;
483
+ break;
484
+
485
+ }
486
+
487
+ if (value) {
488
+ inputByName[cleanName].push(multiple ? values.join(',') : encodeURIComponent(value));
489
+ }
490
+
491
+ }
492
+
493
+ }
494
+ var matchCommon = /name|first name|last name|email|e-mail|phone|website|job title|company|tele|address|comment/;
495
+ for (var inputName in inputByName) {
496
+ if (matchCommon.test(inputName) !== false) {
497
+ console.log(inputName + " Matches Regex");
498
+ /* run mapping loop only for the matches here */
499
+ }
500
+ params.push( inputName + '=' + inputByName[inputName].join(',') );
501
+ }
502
+ var final_params = params.join('&');
503
+ console.log(final_params);
504
+ },
505
+ getInputValue = function(input) {
506
+ var value = false;
507
+
508
+ switch (input.type) {
509
+ case 'radio':
510
+ case 'checkbox':
511
+ if (input.checked) {
512
+ value = input.value;
513
+ }
514
+ break;
515
+
516
+ case 'text':
517
+ case 'hidden':
518
+ default:
519
+ value = input.value;
520
+ break;
521
+
522
+ }
523
+
524
+ return value;
525
+
526
+ },
527
+ /*
528
+ inbound_form_classes: function(forms, functionName, classes) {
529
+ jQuery.each(forms, function(index, id) {
530
+ var selector = jQuery.trim(id);
531
+ for (var this_class in classes) {
532
+ if (selector.indexOf('#')>-1) {
533
+ jQuery(selector)[functionName](classes[this_class]);
534
+ //console.log(selector);
535
+ } else if (selector.indexOf('.')>-1) {
536
+ jQuery(selector)[functionName](classes[this_class]);
537
+ } else {
538
+ jQuery("#" + selector)[functionName](classes[this_class]);
539
+ }
540
+ }
541
+
542
+ });
543
+ }*/
544
+ /* Add tracking class to forms */
545
+ attachFormSubmitEvent: function (form) {
546
+
547
+ console.log("The Form has the class wpl-track-me", hasClass);
548
+ InboundAnalytics.Utils.addListener(form, 'submit', InboundAnalytics.LeadsAPI.formSubmit );
549
+
550
+ },
551
+
552
+
553
+ };
554
+
555
+ return InboundAnalytics;
556
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
  })(InboundAnalytics || {});
558
+ /**
559
+ * Event functions
560
+ * @param Object InboundAnalytics - Main JS object
561
+ * @return Object - include event triggers
562
+ */
563
+ // https://github.com/carldanley/WP-JS-Hooks/blob/master/src/event-manager.js
564
+ var InboundAnalyticsEvents = (function (InboundAnalytics) {
565
+
566
+ InboundAnalytics.Events = {
567
+ // Create cookie
568
+ loadEvents: function() {
569
+ this.analyticsLoaded();
570
+ },
571
+ triggerJQueryEvent: function(eventName, data){
572
+ if (window.jQuery) {
573
+ var data = data || {};
574
+ jQuery(document).trigger(eventName, data);
575
+ /* var something = (function() {
576
+ var executed = false;
577
+ return function () {
578
+ if (!executed) {
579
+ executed = true;
580
+ console.log(eventName + " RAN");
581
+
582
+ }
583
+ };
584
+ })();*/
585
+ }
586
+ },
587
+ analyticsLoaded: function() {
588
+ var eventName = "inbound_analytics_loaded";
589
+ var loaded = new CustomEvent(eventName);
590
+ window.dispatchEvent(loaded);
591
+ this.triggerJQueryEvent(eventName);
592
+ },
593
+ analyticsTriggered: function() {
594
+ var triggered = new CustomEvent("inbound_analytics_triggered");
595
+ window.dispatchEvent(triggered);
596
+ },
597
+ analyticsSaved: function() {
598
+ var page_view_saved = new CustomEvent("inbound_analytics_saved");
599
+ window.dispatchEvent(page_view_saved);
600
+ console.log('Page View Saved');
601
+ },
602
+ analyticsError: function(MLHttpRequest, textStatus, errorThrown) {
603
+ var error = new CustomEvent("inbound_analytics_error", {
604
+ detail: {
605
+ MLHttpRequest: MLHttpRequest,
606
+ textStatus: textStatus,
607
+ errorThrown: errorThrown
608
+ }
609
+ });
610
+ window.dispatchEvent(error);
611
+ console.log('Page Save Error');
612
+ },
613
+ pageFirstView: function(page_seen_count) {
614
+ var page_first_view = new CustomEvent("inbound_analytics_page_first_view", {
615
+ detail: {
616
+ count: 1,
617
+ time: new Date(),
618
+ },
619
+ bubbles: true,
620
+ cancelable: true
621
+ }
622
+ );
623
+ window.dispatchEvent(page_first_view);
624
+
625
+ console.log('First Ever Page View of this Page');
626
+ },
627
+ pageRevisit: function(page_seen_count) {
628
+ var eventName = "inbound_analytics_page_revisit";
629
+ var data = { count: page_seen_count,
630
+ time: new Date()
631
+ };
632
+ var page_revisit = new CustomEvent(eventName, {
633
+ detail: data,
634
+ bubbles: true,
635
+ cancelable: true
636
+ }
637
+ );
638
+ window.dispatchEvent(page_revisit);
639
+ this.triggerJQueryEvent(eventName, data);
640
+ console.log('Page Revisit');
641
+ },
642
+ /* get idle times https://github.com/robflaherty/riveted/blob/master/riveted.js */
643
+ browserTabHidden: function() {
644
+ /* http://www.thefutureoftheweb.com/demo/2007-05-16-detect-browser-window-focus/ */
645
+ var eventName = "inbound_analytics_tab_hidden";
646
+ var tab_hidden = new CustomEvent(eventName);
647
+ window.dispatchEvent(tab_hidden);
648
+ console.log('Tab Hidden');
649
+ this.triggerJQueryEvent(eventName);
650
+ },
651
+ browserTabVisible: function() {
652
+ var eventName = "inbound_analytics_tab_visible";
653
+ var tab_visible = new CustomEvent(eventName);
654
+ window.dispatchEvent(tab_visible);
655
+ console.log('Tab Visible');
656
+ this.triggerJQueryEvent(eventName);
657
+ },
658
+ /* Scrol depth https://github.com/robflaherty/jquery-scrolldepth/blob/master/jquery.scrolldepth.js */
659
+ sessionStart: function() {
660
+ var session_start = new CustomEvent("inbound_analytics_session_start");
661
+ window.dispatchEvent(session_start);
662
+ console.log('Session Start');
663
+ },
664
+ sessionActive: function() {
665
+ var session_active = new CustomEvent("inbound_analytics_session_active");
666
+ window.dispatchEvent(session_active);
667
+ console.log('Session Active');
668
+ },
669
+
670
+ };
671
+
672
+ return InboundAnalytics;
673
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
  })(InboundAnalytics || {});
675
+ /* Fork of jquery.total-storage.js */
676
+ var InboundTotalStorage = (function (InboundAnalytics){
677
+
678
+ /* Variables I'll need throghout */
679
+
680
+ var supported, ls, mod = 'inboundAnalytics';
681
+ if ('localStorage' in window){
682
+ try {
683
+ ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
684
+ if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
685
+ supported = false;
686
+ } else {
687
+ supported = true;
688
+ }
689
+ window.localStorage.setItem(mod, '1');
690
+ window.localStorage.removeItem(mod);
691
+ }
692
+ catch (err){
693
+ supported = false;
694
+ }
695
+ }
696
+
697
+ /* Make the methods public */
698
+ InboundAnalytics.totalStorage = function(key, value, options){
699
+ return InboundAnalytics.totalStorage.impl.init(key, value);
700
+ };
701
+
702
+ InboundAnalytics.totalStorage.setItem = function(key, value){
703
+ return InboundAnalytics.totalStorage.impl.setItem(key, value);
704
+ };
705
+
706
+ InboundAnalytics.totalStorage.getItem = function(key){
707
+ return InboundAnalytics.totalStorage.impl.getItem(key);
708
+ };
709
+
710
+ InboundAnalytics.totalStorage.getAll = function(){
711
+ return InboundAnalytics.totalStorage.impl.getAll();
712
+ };
713
+
714
+ InboundAnalytics.totalStorage.deleteItem = function(key){
715
+ return InboundAnalytics.totalStorage.impl.deleteItem(key);
716
+ };
717
+
718
+ /* Object to hold all methods: public and private */
719
+
720
+ InboundAnalytics.totalStorage.impl = {
721
+
722
+ init: function(key, value){
723
+ if (typeof value != 'undefined') {
724
+ return this.setItem(key, value);
725
+ } else {
726
+ return this.getItem(key);
727
+ }
728
+ },
729
+
730
+ setItem: function(key, value){
731
+ if (!supported){
732
+ try {
733
+ InboundAnalytics.Utils.createCookie(key, value);
734
+ return value;
735
+ } catch(e){
736
+ console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');
737
+ }
738
+ }
739
+ var saver = JSON.stringify(value);
740
+ ls.setItem(key, saver);
741
+ return this.parseResult(saver);
742
+ },
743
+ getItem: function(key){
744
+ if (!supported){
745
+ try {
746
+ return this.parseResult(InboundAnalytics.Utils.readCookie(key));
747
+ } catch(e){
748
+ return null;
749
+ }
750
+ }
751
+ var item = ls.getItem(key);
752
+ return this.parseResult(item);
753
+ },
754
+ deleteItem: function(key){
755
+ if (!supported){
756
+ try {
757
+ InboundAnalytics.Utils.eraseCookie(key, null);
758
+ return true;
759
+ } catch(e){
760
+ return false;
761
+ }
762
+ }
763
+ ls.removeItem(key);
764
+ return true;
765
+ },
766
+ getAll: function(){
767
+ var items = [];
768
+ if (!supported){
769
+ try {
770
+ var pairs = document.cookie.split(";");
771
+ for (var i = 0; i<pairs.length; i++){
772
+ var pair = pairs[i].split('=');
773
+ var key = pair[0];
774
+ items.push({key:key, value:this.parseResult(InboundAnalytics.Utils.readCookie(key))});
775
+ }
776
+ } catch(e){
777
+ return null;
778
+ }
779
+ } else {
780
+ for (var j in ls){
781
+ if (j.length){
782
+ items.push({key:j, value:this.parseResult(ls.getItem(j))});
783
+ }
784
+ }
785
+ }
786
+ return items;
787
+ },
788
+ parseResult: function(res){
789
+ var ret;
790
+ try {
791
+ ret = JSON.parse(res);
792
+ if (typeof ret == 'undefined'){
793
+ ret = res;
794
+ }
795
+ if (ret == 'true'){
796
+ ret = true;
797
+ }
798
+ if (ret == 'false'){
799
+ ret = false;
800
+ }
801
+ if (parseFloat(ret) == ret && typeof ret != "object"){
802
+ ret = parseFloat(ret);
803
+ }
804
+ } catch(e){
805
+ ret = res;
806
+ }
807
+ return ret;
808
+ }
809
+ };
810
+ })(InboundAnalytics || {});
811
+ /**
812
+ * Leads API functions
813
+ * @param Object InboundAnalytics - Main JS object
814
+ * @return Object - include event triggers
815
+ */
816
+ var InboundAnalyticsLeadsAPI = (function (InboundAnalytics) {
817
+ var httpRequest;
818
+ InboundAnalytics.LeadsAPI = {
819
+ init: function() {
820
+
821
+ },
822
+ storeLeadData: function(){
823
+ if(element.addEventListener) {
824
+ element.addEventListener("submit", function(evt){
825
+ evt.preventDefault();
826
+ window.history.back();
827
+ }, true);
828
+ } else {
829
+ element.attachEvent('onsubmit', function(evt){
830
+ evt.preventDefault();
831
+ window.history.back();
832
+ });
833
+ }
834
+ },
835
+ inbound_map_fields: function (el, value, Obj) {
836
+ var formObj = [];
837
+ var $this = el;
838
+ var clean_output = value;
839
+ var label = $this.closest('label').text();
840
+ var exclude = ['credit-card']; // exlcude values from formObj
841
+ var inarray = jQuery.inArray(clean_output, exclude);
842
+ if(inarray == 0){
843
+ return null;
844
+ }
845
+ // Add items to formObj
846
+ formObj.push({
847
+ field_label: label,
848
+ field_name: $this.attr("name"),
849
+ field_value: $this.attr("value"),
850
+ field_id: $this.attr("id"),
851
+ field_class: $this.attr("class"),
852
+ field_type: $this.attr("type"),
853
+ match: clean_output,
854
+ js_selector: $this.attr("data-js-selector")
855
+ });
856
+ return formObj;
857
+ },
858
+ run_field_map_function: function (el, lookingfor) {
859
+ var return_form;
860
+ var formObj = new Array();
861
+ var $this = el;
862
+ var body = jQuery("body");
863
+ var input_id = $this.attr("id") || "NULL";
864
+ var input_name = $this.attr("name") || "NULL";
865
+ var this_val = $this.attr("value");
866
+ var array = lookingfor.split(",");
867
+ var array_length = array.length - 1;
868
+
869
+ // Main Loop
870
+ for (var i = 0; i < array.length; i++) {
871
+ var clean_output = InboundAnalytics.Utils.trim(array[i]);
872
+ var nice_name = clean_output.replace(/^\s+|\s+$/g,'');
873
+ var nice_name = nice_name.replace(" ",'_');
874
+ var in_object_already = nice_name in inbound_data;
875
+ //console.log(clean_output);
876
+
877
+ if (input_name.toLowerCase().indexOf(clean_output)>-1) {
878
+ /* Look for attr name match */
879
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
880
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
881
+ console.log('match name: ' + clean_output);
882
+ console.log(nice_name in inbound_data);
883
+ if (!in_object_already) {
884
+ inbound_data[nice_name] = this_val;
885
+ }
886
+ } else if (input_id.toLowerCase().indexOf(clean_output)>-1) {
887
+ /* look for id match */
888
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
889
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
890
+ console.log('match id: ' + clean_output);
891
+
892
+ if (!in_object_already) {
893
+ inbound_data[nice_name] = this_val;
894
+ }
895
+
896
+ } else if ($this.closest('li').children('label').length>0) {
897
+ /* Look for label name match */
898
+ var closest_label = $this.closest('li').children('label').html() || "NULL";
899
+ if (closest_label.toLowerCase().indexOf(clean_output)>-1) {
900
+
901
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
902
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
903
+ console.log($this.context);
904
+
905
+ var exists_in_dom = body.find("[data-inbound-form-map='inbound_map_" + nice_name + "']").length;
906
+ console.log(exists_in_dom);
907
+ console.log('match li: ' + clean_output);
908
+
909
+ if (!in_object_already) {
910
+ inbound_data[nice_name] = this_val;
911
+ }
912
+
913
+ }
914
+ } else if ($this.closest('div').children('label').length>0) {
915
+ /* Look for closest div label name match */
916
+ var closest_div = $this.closest('div').children('label').html() || "NULL";
917
+ if (closest_div.toLowerCase().indexOf(clean_output)>-1)
918
+ {
919
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
920
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
921
+ console.log('match div: ' + clean_output);
922
+ if (!in_object_already) {
923
+ inbound_data[nice_name] = this_val;
924
+ }
925
+ }
926
+ } else if ($this.closest('p').children('label').length>0) {
927
+ /* Look for closest p label name match */
928
+ var closest_p = $this.closest('p').children('label').html() || "NULL";
929
+ if (closest_p.toLowerCase().indexOf(clean_output)>-1)
930
+ {
931
+ var the_map = InboundAnalytics.LeadsAPI.inbound_map_fields($this, clean_output, formObj);
932
+ InboundAnalytics.LeadsAPI.add_inbound_form_class($this, clean_output);
933
+ console.log('match p: ' + clean_output);
934
+ if (!in_object_already) {
935
+ inbound_data[nice_name] = this_val;
936
+ }
937
+ }
938
+ } else {
939
+ console.log('Need additional mapping data');
940
+ }
941
+ }
942
+ return_form = the_map;
943
+
944
+ return inbound_data;
945
+ },
946
+ add_inbound_form_class: function(el, value) {
947
+ var value = value.replace(" ", "_");
948
+ var value = value.replace("-", "_");
949
+ el.addClass('inbound_map_value');
950
+ el.attr('data-inbound-form-map', 'inbound_map_' + value);
951
+ },
952
+ inbound_form_type: function(this_form) {
953
+ var inbound_data = inbound_data || {},
954
+ form_type = 'normal';
955
+ if ( this_form.is( ".wpl-comment-form" ) ) {
956
+ inbound_data['form_type'] = 'comment';
957
+ form_type = 'comment';
958
+ } else if ( this_form.is( ".wpl-search-box" ) ) {
959
+ var is_search = true;
960
+ form_type = 'search';
961
+ inbound_data['form_type'] = 'search';
962
+ } else if ( this_form.is( '.wpl-track-me-link' ) ){
963
+ var have_email = readCookie('wp_lead_email');
964
+ console.log(have_email);
965
+ inbound_data['form_type'] = 'link';
966
+ form_type = 'search';
967
+ }
968
+ return form_type;
969
+ },
970
+ grab_all_form_input_vals: function(this_form){
971
+ var post_values = post_values || {},
972
+ inbound_exclude = inbound_exclude || [],
973
+ form_inputs = this_form.find('input,textarea,select');
974
+ inbound_exclude.push('inbound_furl', 'inbound_current_page_url', 'inbound_notify', 'inbound_submitted', 'post_type', 'post_status', 's', 'inbound_form_name', 'inbound_form_id', 'inbound_form_lists');
975
+ var form_type = InboundAnalytics.LeadsAPI.inbound_form_type(this_form),
976
+ inbound_data = inbound_data || {},
977
+ email = inbound_data['email'] || false;
978
+
979
+ form_inputs.each(function() {
980
+ var $input = jQuery(this),
981
+ input_type = $input.attr('type'),
982
+ input_val = $input.val();
983
+ if (input_type === 'checkbox') {
984
+ input_checked = $input.attr("checked");
985
+ console.log(input_val);
986
+ console.log(input_checked);
987
+ console.log(post_values[this.name]);
988
+ if (input_checked === "checked"){
989
+ if (typeof (post_values[this.name]) != "undefined") {
990
+ post_values[this.name] = post_values[this.name] + "," + input_val;
991
+ console.log(post_values[this.name]);
992
+ } else {
993
+ post_values[this.name] = input_val;
994
+ }
995
+
996
+ }
997
+ }
998
+ if (jQuery.inArray(this.name, inbound_exclude) === -1 && input_type != 'checkbox'){
999
+ post_values[this.name] = input_val;
1000
+ }
1001
+ if (this.value.indexOf('@')>-1&&!email){
1002
+ email = input_val;
1003
+ inbound_data['email'] = email;
1004
+ }
1005
+ if (form_type === 'search') {
1006
+ inbound_data['search_keyword'] = input_val.replace('"', "'");
1007
+ }
1008
+ });
1009
+ var all_form_fields = JSON.stringify(post_values);
1010
+ return all_form_fields;
1011
+ },
1012
+ return_mapped_values: function (this_form) {
1013
+ // Map form fields
1014
+ jQuery(this_form).find('input[type!="hidden"],textarea,select').each(function() {
1015
+ console.log('run');
1016
+ var this_input = jQuery(this);
1017
+ var this_input_val = this_input.val();
1018
+ if (typeof (this_input_val) != "undefined" && this_input_val != null && this_input_val != "") {
1019
+ var inbound_data = InboundAnalytics.LeadsAPI.run_field_map_function( this_input, "name, first name, last name, email, e-mail, phone, website, job title, company, tele, address, comment");
1020
+ }
1021
+ return inbound_data;
1022
+ });
1023
+ return inbound_data;
1024
+ },
1025
+ inbound_form_submit: function(this_form, e) {
1026
+ /* Define Variables */
1027
+ var data = inbound_data || {};
1028
+ // Dynamic JS object for passing custom values. This can be hooked into by third parties by using the below syntax.
1029
+ var pageviewObj = jQuery.totalStorage('page_views');
1030
+ data['page_view_count'] = InboundAnalytics.Utils.countProperties(pageviewObj);
1031
+ data['leads_list'] = jQuery(this_form).find('#inbound_form_lists').val();
1032
+ data['source'] = jQuery.cookie("wp_lead_referral_site") || "NA";
1033
+ data['page_id'] = inbound_ajax.post_id;
1034
+ data['page_views'] = JSON.stringify(pageviewObj);
1035
+
1036
+ // Map form fields
1037
+ var returned_form_data = InboundAnalytics.LeadsAPI.return_mapped_values(this_form); //console.log(returned_form_data);
1038
+ var data = InboundAnalytics.Utils.mergeObjs(data,returned_form_data); //console.log(data);
1039
+ var this_form = jQuery(this_form);
1040
+ // Set variables after mapping
1041
+ data['email'] = (!data['email']) ? this_form.find('.inbound-email').val() : data['email'];
1042
+ data['form_name'] = this_form.find('.inbound_form_name').val() || "Not Found";
1043
+ data['form_id'] = this_form.find('.inbound_form_id').val() || "Not Found";
1044
+ data['first_name'] = (!data['first_name']) ? data['name'] : data['first_name'];
1045
+ data['last_name'] = data['last_name'] || '';
1046
+ data['phone'] = data['phone'] || '';
1047
+ data['company'] = data['company'] || '';
1048
+ data['address'] = data['address'] || '';
1049
+
1050
+ // Fallbacks for values
1051
+ data['name'] = (data['first_name'] && data['last_name']) ? data['first_name'] + " " + data['last_name'] : data['name'];
1052
+
1053
+ if (!data['last_name'] && data['first_name']) {
1054
+ var parts = data['first_name'].split(" ");
1055
+ data['first_name'] = parts[0];
1056
+ data['last_name'] = parts[1];
1057
+ }
1058
+
1059
+ /* Store form fields & exclude field values */
1060
+ var all_form_fields = InboundAnalytics.LeadsAPI.grab_all_form_input_vals(this_form);
1061
+ /* end Store form fields & exclude field values */
1062
+
1063
+ if(data['email']){
1064
+ InboundAnalytics.Utils.createCookie("wp_lead_email", data['email'], 365); /* set email cookie */
1065
+ }
1066
+
1067
+ //var variation = (typeof (landing_path_info) != "undefined") ? landing_path_info.variation : false;
1068
+
1069
+ if (typeof (landing_path_info) != "undefined") {
1070
+ var variation = landing_path_info.variation;
1071
+ } else if (typeof (cta_path_info) != "undefined") {
1072
+ var variation = cta_path_info.variation;
1073
+ } else {
1074
+ var variation = 0;
1075
+ }
1076
+
1077
+ data['variation'] = variation;
1078
+ data['post_type'] = inbound_ajax.post_type;
1079
+ data['wp_lead_uid'] = jQuery.cookie("wp_lead_uid") || null;
1080
+ data['ip_address'] = inbound_ajax.ip_address;
1081
+ data['search_data'] = JSON.stringify(jQuery.totalStorage('inbound_search')) || {};
1082
+
1083
+ var lp_check = (inbound_ajax.post_type === 'landing-page') ? 'Landing Page' : "";
1084
+ var cta_check = (inbound_ajax.post_type === 'wp-call-to-action') ? 'Call to Action' : "";
1085
+ var page_type = (!cta_check && !lp_check) ? inbound_ajax.post_type : lp_check + cta_check;
1086
+
1087
+ // jsonify data
1088
+ var mapped_form_data = JSON.stringify(data);
1089
+
1090
+ var return_data = {};
1091
+ var return_data = {
1092
+ "action": 'inbound_store_lead',
1093
+ "emailTo": data['email'],
1094
+ "first_name": data['first_name'],
1095
+ "last_name": data['last_name'],
1096
+ "phone": data['phone'],
1097
+ "address": data['address'],
1098
+ "company_name": data['company'],
1099
+ "page_views": data['page_views'],
1100
+ "form_input_values": all_form_fields,
1101
+ "Mapped_Data": mapped_form_data,
1102
+ "Search_Data": data['search_data']
1103
+ }
1104
+ return return_data;
1105
+ },
1106
+ formSubmit: function (e){
1107
+ /*if(!confirm('Are you sure?')) {
1108
+ e.returnValue = false;
1109
+ if(e.preventDefault) e.preventDefault();
1110
+ return false;
1111
+ }
1112
+ return true;*/
1113
+ /*var inbound_data = inbound_data || {},
1114
+ this_form = e.target,
1115
+ event_type = e.type,
1116
+ is_search = false,
1117
+ form_type = 'normal';*/
1118
+
1119
+ e.preventDefault(); /* Halt form processing */
1120
+ console.log("This works");
1121
+ var data = InboundAnalytics.LeadsAPI.inbound_form_submit(e.target, e); // big function for processing
1122
+ console.log(data);
1123
+ alert('Working');
1124
+ //document.getElementById("ajaxButton").onclick = function() { makeRequest('test.html'); };
1125
+
1126
+ /* Final Ajax Call on Submit */
1127
+ InboundAnalytics.LeadsAPI.makeRequest('test.html');
1128
+ },
1129
+ alertContents: function() {
1130
+ if (httpRequest.readyState === 4) {
1131
+ if (httpRequest.status === 200) {
1132
+ alert(httpRequest.responseText);
1133
+ } else if(xmlhttp.status == 400) {
1134
+ alert('There was an error 400');
1135
+ } else {
1136
+ alert('There was a problem with the request.');
1137
+ }
1138
+ }
1139
+ },
1140
+ getAllLeadData: function(expire_check) {
1141
+ var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id"),
1142
+ old_data = jQuery.totalStorage('inbound_lead_data'),
1143
+ data = {
1144
+ action: 'inbound_get_all_lead_data',
1145
+ wp_lead_id: wp_lead_id,
1146
+ },
1147
+ success = function(returnData){
1148
+ var obj = JSON.parse(returnData);
1149
+ console.log('Got all the lead data check ');
1150
+ setGlobalLeadVar(obj);
1151
+ jQuery.totalStorage('inbound_lead_data', obj); // store lead data
1152
+ };
1153
+
1154
+ if(!old_data) {
1155
+ console.log("No old data");
1156
+ }
1157
+
1158
+ if (expire_check === 'true'){
1159
+ console.log("Session has not expired");
1160
+ }
1161
+
1162
+ if(!old_data && expire_check === null) {
1163
+ InboundAnalytics.debug('Go to Database',function(){
1164
+ console.log(expire_check);
1165
+ console.log(old_data);
1166
+ });
1167
+ InboundAnalytics.Utils.doAjax(data, success);
1168
+ } else {
1169
+ setGlobalLeadVar(old_data); // set global lead var with localstorage data
1170
+ var lead_data_expiration = InboundAnalytics.Utils.readCookie("lead_data_expiration");
1171
+ if (lead_data_expiration === null) {
1172
+ InboundAnalytics.Utils.doAjax(data, success);
1173
+ console.log('localized data old. Pull new from DB');
1174
+ }
1175
+ }
1176
+
1177
+ },
1178
+ getLeadLists: function() {
1179
+ var wp_lead_id = InboundAnalytics.Utils.readCookie("wp_lead_id");
1180
+ var data = {
1181
+ action: 'wpl_check_lists',
1182
+ wp_lead_id: wp_lead_id,
1183
+ };
1184
+ var success = function(user_id){
1185
+ jQuery.cookie("lead_session_list_check", true, { path: '/', expires: 1 });
1186
+ console.log("Lists checked");
1187
+ };
1188
+ InboundAnalytics.Utils.doAjax(data, success);
1189
+ }
1190
+ };
1191
+
1192
+ return InboundAnalytics;
1193
+
1194
+ })(InboundAnalytics || {});
1195
+ var InboundAnalyticsPageTracking = (function (InboundAnalytics) {
1196
+
1197
+ InboundAnalytics.PageTracking = {
1198
+
1199
+ getPageViews: function () {
1200
+ var local_store = InboundAnalytics.Utils.checkLocalStorage();
1201
+ if(local_store){
1202
+ var page_views = localStorage.getItem("page_views"),
1203
+ local_object = JSON.parse(page_views);
1204
+ if (typeof local_object =='object' && local_object) {
1205
+ this.StorePageView();
1206
+ }
1207
+ return local_object;
1208
+ }
1209
+ },
1210
+ StorePageView: function() {
1211
+ var timeout = this.CheckTimeOut();
1212
+ var pageviewObj = jQuery.totalStorage('page_views');
1213
+ if(pageviewObj === null) {
1214
+ pageviewObj = {};
1215
+ }
1216
+ var current_page_id = wplft.post_id;
1217
+ var datetime = InboundAnalytics.Utils.GetDate();
1218
+
1219
+ if (timeout) {
1220
+ // If pageviewObj exists, do this
1221
+ var page_seen = pageviewObj[current_page_id];
1222
+
1223
+ if(typeof(page_seen) != "undefined" && page_seen !== null) {
1224
+ pageviewObj[current_page_id].push(datetime);
1225
+ /* Page Revisit Trigger */
1226
+ var page_seen_count = pageviewObj[current_page_id].length;
1227
+ InboundAnalytics.Events.pageRevisit(page_seen_count);
1228
+
1229
+ } else {
1230
+ pageviewObj[current_page_id] = [];
1231
+ pageviewObj[current_page_id].push(datetime);
1232
+ /* Page First Seen Trigger */
1233
+ var page_seen_count = 1;
1234
+ InboundAnalytics.Events.pageFirstView(page_seen_count);
1235
+ }
1236
+
1237
+ jQuery.totalStorage('page_views', pageviewObj);
1238
+
1239
+ }
1240
+ },
1241
+ CheckTimeOut: function() {
1242
+ var PageViews = jQuery.totalStorage('page_views');
1243
+ if(PageViews === null) {
1244
+ var PageViews = {};
1245
+ }
1246
+ var page_id = wplft.post_id,
1247
+ pageviewTimeout = true, /* Default */
1248
+ page_seen = PageViews[page_id];
1249
+ if(typeof(page_seen) != "undefined" && page_seen !== null) {
1250
+
1251
+ var time_now = InboundAnalytics.Utils.GetDate(),
1252
+ vc = PageViews[page_id].length - 1,
1253
+ last_view = PageViews[page_id][vc],
1254
+ last_view_ms = new Date(last_view).getTime(),
1255
+ time_now_ms = new Date(time_now).getTime(),
1256
+ timeout_ms = last_view_ms + 30*1000,
1257
+ time_check = Math.abs(last_view_ms - time_now_ms),
1258
+ wait_time = 30000;
1259
+
1260
+ InboundAnalytics.debug('Timeout Checks =',function(){
1261
+ console.log('Current Time is: ' + time_now);
1262
+ console.log('Last view is: ' + last_view);
1263
+ console.log("Last view milliseconds " + last_view_ms);
1264
+ console.log("time now milliseconds " + time_now_ms);
1265
+ console.log("Wait Check: " + wait_time);
1266
+ console.log("TIME CHECK: " + time_check);
1267
+ });
1268
+
1269
+ //var wait_time = Math.abs(last_view_ms - timeout_ms) // output timeout time 30sec;
1270
+
1271
+ if (time_check < wait_time){
1272
+ time_left = Math.abs((wait_time - time_check)) * .001;
1273
+ pageviewTimeout = false;
1274
+ var status = '30 sec timeout not done: ' + time_left + " seconds left";
1275
+ } else {
1276
+ var status = 'Timeout Happened. Page view fired';
1277
+ this.firePageView();
1278
+ pageviewTimeout = true;
1279
+ InboundAnalytics.Events.analyticsTriggered();
1280
+ }
1281
+
1282
+ //InboundAnalytics.debug('',function(){
1283
+ console.log(status);
1284
+ //});
1285
+ } else {
1286
+ /* Page never seen before */
1287
+ this.firePageView();
1288
+ }
1289
+
1290
+ return pageviewTimeout;
1291
+
1292
+ },
1293
+ firePageView: function() {
1294
+ var lead_id = InboundAnalytics.Utils.readCookie('wp_lead_id'),
1295
+ lead_uid = InboundAnalytics.Utils.readCookie('wp_lead_uid');
1296
+
1297
+ if (typeof (lead_id) != "undefined" && lead_id != null && lead_id != "") {
1298
+
1299
+ InboundAnalytics.debug('Run page view ajax');
1300
+
1301
+ var data = {
1302
+ action: 'wpl_track_user',
1303
+ wp_lead_uid: lead_uid,
1304
+ wp_lead_id: lead_id,
1305
+ page_id: wplft.post_id,
1306
+ current_url: window.location.href,
1307
+ json: '0'
1308
+ };
1309
+ var firePageCallback = function(user_id){
1310
+ InboundAnalytics.Events.analyticsSaved();
1311
+ };
1312
+ InboundAnalytics.Utils.doAjax(data, firePageCallback);
1313
+ }
1314
+ },
1315
+ tabSwitch: function() {
1316
+ /* test out simplier script
1317
+ function onBlur() {
1318
+ document.body.className = 'blurred';
1319
+ };
1320
+ function onFocus(){
1321
+ document.body.className = 'focused';
1322
+ };
1323
+
1324
+ if (false) { // check for Internet Explorer
1325
+ document.onfocusin = onFocus;
1326
+ document.onfocusout = onBlur;
1327
+ } else {
1328
+ window.onfocus = onFocus;
1329
+ window.onblur = onBlur;
1330
+ }
1331
+ */
1332
+
1333
+ var hidden, visibilityState, visibilityChange;
1334
+
1335
+ if (typeof document.hidden !== "undefined") {
1336
+ hidden = "hidden", visibilityChange = "visibilitychange", visibilityState = "visibilityState";
1337
+ } else if (typeof document.mozHidden !== "undefined") {
1338
+ hidden = "mozHidden", visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState";
1339
+ } else if (typeof document.msHidden !== "undefined") {
1340
+ hidden = "msHidden", visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState";
1341
+ } else if (typeof document.webkitHidden !== "undefined") {
1342
+ hidden = "webkitHidden", visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState";
1343
+ } // if
1344
+
1345
+ var document_hidden = document[hidden];
1346
+
1347
+ document.addEventListener(visibilityChange, function() {
1348
+ if(document_hidden != document[hidden]) {
1349
+ if(document[hidden]) {
1350
+ // Document hidden
1351
+ console.log('hidden');
1352
+ InboundAnalytics.Events.browserTabHidden();
1353
+ } else {
1354
+ // Document shown
1355
+ console.log('shown');
1356
+ InboundAnalytics.Events.browserTabVisible();
1357
+ } // if
1358
+
1359
+ document_hidden = document[hidden];
1360
+ } // if
1361
+ });
1362
+ }
1363
+ }
1364
+
1365
+ return InboundAnalytics;
1366
+
1367
+ })(InboundAnalytics || {});
1368
+ /**
1369
+ * Init Inbound Analytics
1370
+ * - initializes analytics
1371
+ */
1372
+
1373
+ var InboundLeadData = jQuery.totalStorage('inbound_lead_data') || null;
1374
+ function setGlobalLeadVar(retString){
1375
+ InboundLeadData = retString;
1376
+ }
1377
+
1378
+ InboundAnalytics.init(); // run analytics
1379
+
1380
+ /* run on ready */
1381
+ jQuery(document).ready(function($) {
1382
+ //record non conversion status
1383
+ var in_u = InboundAnalytics.Utils,
1384
+ wp_lead_uid = in_u.readCookie("wp_lead_uid"),
1385
+ wp_lead_id = in_u.readCookie("wp_lead_id"),
1386
+ expire_check = in_u.readCookie("lead_session_expire"); // check for session
1387
+
1388
+ if (expire_check === null) {
1389
+ console.log('expired vistor. Run Processes');
1390
+ //var data_to_lookup = global-localized-vars;
1391
+ if (typeof (wp_lead_id) != "undefined" && wp_lead_id != null && wp_lead_id != "") {
1392
+ /* Get InboundLeadData */
1393
+ InboundAnalytics.LeadsAPI.getAllLeadData(expire_check);
1394
+ /* Lead list check */
1395
+ InboundAnalytics.LeadsAPI.getLeadLists();
1396
+ }
1397
+ }
1398
+
1399
+ //window.addEventListener('load',function(){
1400
+ // InboundAnalytics.LeadsAPI.attachSubmitEvent(window,InboundAnalytics.LeadsAPI.formSubmit);
1401
+ //}, false);
1402
+
1403
+ in_u.contentLoaded(window, InboundAnalytics.LeadsAPI.attachFormSubmitEvent);
1404
+
1405
+ /* Set Session Timeout */
1406
+ in_u.SetSessionTimeout();
1407
+
1408
  });
shared/classes/class.form.php CHANGED
@@ -166,6 +166,7 @@ class Inbound_Forms {
166
  if ($map_field != "") {
167
  $field_name = $map_field;
168
  } else {
 
169
  $field_name = strtolower(str_replace(array(' ','_'),'-',$label));
170
  }
171
 
@@ -199,7 +200,7 @@ class Inbound_Forms {
199
  }
200
 
201
  if ($type === 'textarea') {
202
- $form .= '<textarea class="inbound-input inbound-input-textarea '.$field_input_class.'" name="'.$field_name.'" id="in_'.$field_name.'" '.$req.'/>'.$placeholder_use.'</textarea>';
203
  }
204
  else if ($type === 'dropdown')
205
  {
@@ -294,7 +295,7 @@ class Inbound_Forms {
294
 
295
  $required_id = ( $key == 0 ) ? $req : '';
296
 
297
- $form .= '<input class="checkbox-'.$main_layout.' checkbox-'.$form_labels_class.' '.$field_input_class.'" type="checkbox" name="'. $field_name .'[]" value="'. $checkbox_val .'" '.$required_id.'>'.$value.'<br>';
298
  }
299
  } else if ($type === 'html-block') {
300
  $html = $matches[3][$i]['html'];
@@ -343,7 +344,21 @@ class Inbound_Forms {
343
  return $form;
344
  }
345
  }
346
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  /* Create shorter shortcode for [inbound_forms] */
348
  static function inbound_short_form_create( $atts, $content = null )
349
  {
@@ -406,8 +421,216 @@ class Inbound_Forms {
406
  return;
407
 
408
  echo '<script type="text/javascript">
409
- jQuery(document).ready(function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
  jQuery("form").submit(function(e) {
413
  jQuery(this).find("input").each(function(){
@@ -420,7 +643,25 @@ class Inbound_Forms {
420
  }
421
  });
422
  });
423
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  jQuery("#inbound_form_submit br").remove(); // remove br tags
425
  function validateEmail(email) {
426
 
@@ -434,6 +675,7 @@ class Inbound_Forms {
434
  // validate email
435
  $("input.inbound-email").on("change keyup", function (e) {
436
  var email = $(this).val();
 
437
  if (validateEmail(email)) {
438
  $(this).css("color", "green");
439
  $(this).addClass("valid-email");
@@ -453,6 +695,13 @@ class Inbound_Forms {
453
 
454
  echo "<style type='text/css'>
455
  /* Add button style options http://medleyweb.com/freebies/50-super-sleek-css-button-style-snippets/ */
 
 
 
 
 
 
 
456
  input.invalid-email {-webkit-box-shadow: 0 0 6px #F8B9B7;
457
  -moz-box-shadow: 0 0 6px #f8b9b7;
458
  box-shadow: 0 0 6px #F8B9B7;
@@ -556,11 +805,12 @@ class Inbound_Forms {
556
  $field = "wpleads_work_phone";
557
  }
558
 
559
- $form_post_data[$field] = strip_tags( $value );
 
560
  }
561
 
562
  $form_meta_data['post_id'] = $_POST['inbound_form_id']; // pass in form id
563
-
564
  /* Send emails if passes spam check returns false */
565
  if ( !apply_filters( 'inbound_check_if_spam' , false , $form_post_data ) ) {
566
  self::send_conversion_admin_notification($form_post_data , $form_meta_data);
@@ -601,7 +851,7 @@ class Inbound_Forms {
601
  if ( !isset($form_meta_data['inbound_notify_email']) ) {
602
  return;
603
  }
604
-
605
  /* Get Email We Should Send Notifications To */
606
  $email_to = $form_meta_data['inbound_notify_email'];
607
 
@@ -726,12 +976,12 @@ class Inbound_Forms {
726
 
727
 
728
  $confirm_subject = $Inbound_Templating_Engine->replace_tokens( $confirm_subject, array($form_post_data, $form_meta_data ));
729
-
730
  /* add default subject if empty */
731
  if (!$confirm_subject) {
732
  $confirm_subject = __( 'Thank you!' , 'leads' );
733
  }
734
-
735
  $confirm_email_message = $Inbound_Templating_Engine->replace_tokens( $confirm_email_message , array( $form_post_data, $form_meta_data ) );
736
 
737
 
166
  if ($map_field != "") {
167
  $field_name = $map_field;
168
  } else {
169
+ $label = self::santize_inputs($label);
170
  $field_name = strtolower(str_replace(array(' ','_'),'-',$label));
171
  }
172
 
200
  }
201
 
202
  if ($type === 'textarea') {
203
+ $form .= '<textarea placeholder="'.$placeholder_use.'" class="inbound-input inbound-input-textarea '.$field_input_class.'" name="'.$field_name.'" id="in_'.$field_name.'" '.$req.'/></textarea>';
204
  }
205
  else if ($type === 'dropdown')
206
  {
295
 
296
  $required_id = ( $key == 0 ) ? $req : '';
297
 
298
+ $form .= '<input class="checkbox-'.$main_layout.' checkbox-'.$form_labels_class.' '.$field_input_class.'" type="checkbox" name="'. $field_name .'[]" value="'. $checkbox_val .'" '.$required_id.'>'.$checkbox_val_trimmed.'<br>';
299
  }
300
  } else if ($type === 'html-block') {
301
  $html = $matches[3][$i]['html'];
344
  return $form;
345
  }
346
  }
347
+ static function santize_inputs($content){
348
+ // Strip HTML Tags
349
+ $clear = strip_tags($content);
350
+ // Clean up things like &amp;
351
+ $clear = html_entity_decode($clear);
352
+ // Strip out any url-encoded stuff
353
+ $clear = urldecode($clear);
354
+ // Replace non-AlNum characters with space
355
+ $clear = preg_replace('/[^A-Za-z0-9]/', ' ', $clear);
356
+ // Replace Multiple spaces with single space
357
+ $clear = preg_replace('/ +/', ' ', $clear);
358
+ // Trim the string of leading/trailing space
359
+ $clear = trim($clear);
360
+ return $clear;
361
+ }
362
  /* Create shorter shortcode for [inbound_forms] */
363
  static function inbound_short_form_create( $atts, $content = null )
364
  {
421
  return;
422
 
423
  echo '<script type="text/javascript">
424
+ if (typeof Mailcheck === "undefined") {
425
+ var Mailcheck = {
426
+ domainThreshold: 1,
427
+ topLevelThreshold: 3,
428
+
429
+ defaultDomains: ["yahoo.com", "google.com", "hotmail.com", "gmail.com", "me.com", "aol.com", "mac.com",
430
+ "live.com", "comcast.net", "googlemail.com", "msn.com", "hotmail.co.uk", "yahoo.co.uk",
431
+ "facebook.com", "verizon.net", "sbcglobal.net", "att.net", "gmx.com", "mail.com", "outlook.com", "icloud.com"],
432
+
433
+ defaultTopLevelDomains: ["co.jp", "co.uk", "com", "net", "org", "info", "edu", "gov", "mil", "ca"],
434
+
435
+ run: function(opts) {
436
+ opts.domains = opts.domains || Mailcheck.defaultDomains;
437
+ opts.topLevelDomains = opts.topLevelDomains || Mailcheck.defaultTopLevelDomains;
438
+ opts.distanceFunction = opts.distanceFunction || Mailcheck.sift3Distance;
439
+
440
+ var defaultCallback = function(result){ return result };
441
+ var suggestedCallback = opts.suggested || defaultCallback;
442
+ var emptyCallback = opts.empty || defaultCallback;
443
+
444
+ var result = Mailcheck.suggest(Mailcheck.encodeEmail(opts.email), opts.domains, opts.topLevelDomains, opts.distanceFunction);
445
+
446
+ return result ? suggestedCallback(result) : emptyCallback()
447
+ },
448
+
449
+ suggest: function(email, domains, topLevelDomains, distanceFunction) {
450
+ email = email.toLowerCase();
451
+
452
+ var emailParts = this.splitEmail(email);
453
+
454
+ var closestDomain = this.findClosestDomain(emailParts.domain, domains, distanceFunction, this.domainThreshold);
455
+
456
+ if (closestDomain) {
457
+ if (closestDomain != emailParts.domain) {
458
+ // The email address closely matches one of the supplied domains; return a suggestion
459
+ return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
460
+ }
461
+ } else {
462
+ // The email address does not closely match one of the supplied domains
463
+ var closestTopLevelDomain = this.findClosestDomain(emailParts.topLevelDomain, topLevelDomains, distanceFunction, this.topLevelThreshold);
464
+ if (emailParts.domain && closestTopLevelDomain && closestTopLevelDomain != emailParts.topLevelDomain) {
465
+ // The email address may have a mispelled top-level domain; return a suggestion
466
+ var domain = emailParts.domain;
467
+ closestDomain = domain.substring(0, domain.lastIndexOf(emailParts.topLevelDomain)) + closestTopLevelDomain;
468
+ return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
469
+ }
470
+ }
471
+ /* The email address exactly matches one of the supplied domains, does not closely
472
+ * match any domain and does not appear to simply have a mispelled top-level domain,
473
+ * or is an invalid email address; do not return a suggestion.
474
+ */
475
+ return false;
476
+ },
477
+
478
+ findClosestDomain: function(domain, domains, distanceFunction, threshold) {
479
+ threshold = threshold || this.topLevelThreshold;
480
+ var dist;
481
+ var minDist = 99;
482
+ var closestDomain = null;
483
+
484
+ if (!domain || !domains) {
485
+ return false;
486
+ }
487
+ if(!distanceFunction) {
488
+ distanceFunction = this.sift3Distance;
489
+ }
490
+
491
+ for (var i = 0; i < domains.length; i++) {
492
+ if (domain === domains[i]) {
493
+ return domain;
494
+ }
495
+ dist = distanceFunction(domain, domains[i]);
496
+ if (dist < minDist) {
497
+ minDist = dist;
498
+ closestDomain = domains[i];
499
+ }
500
+ }
501
+
502
+ if (minDist <= threshold && closestDomain !== null) {
503
+ return closestDomain;
504
+ } else {
505
+ return false;
506
+ }
507
+ },
508
+
509
+ sift3Distance: function(s1, s2) {
510
+ // sift3: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
511
+ if (s1 == null || s1.length === 0) {
512
+ if (s2 == null || s2.length === 0) {
513
+ return 0;
514
+ } else {
515
+ return s2.length;
516
+ }
517
+ }
518
+
519
+ if (s2 == null || s2.length === 0) {
520
+ return s1.length;
521
+ }
522
+
523
+ var c = 0;
524
+ var offset1 = 0;
525
+ var offset2 = 0;
526
+ var lcs = 0;
527
+ var maxOffset = 5;
528
+
529
+ while ((c + offset1 < s1.length) && (c + offset2 < s2.length)) {
530
+ if (s1.charAt(c + offset1) == s2.charAt(c + offset2)) {
531
+ lcs++;
532
+ } else {
533
+ offset1 = 0;
534
+ offset2 = 0;
535
+ for (var i = 0; i < maxOffset; i++) {
536
+ if ((c + i < s1.length) && (s1.charAt(c + i) == s2.charAt(c))) {
537
+ offset1 = i;
538
+ break;
539
+ }
540
+ if ((c + i < s2.length) && (s1.charAt(c) == s2.charAt(c + i))) {
541
+ offset2 = i;
542
+ break;
543
+ }
544
+ }
545
+ }
546
+ c++;
547
+ }
548
+ return (s1.length + s2.length) /2 - lcs;
549
+ },
550
+
551
+ splitEmail: function(email) {
552
+ var parts = email.trim().split("@");
553
+
554
+ if (parts.length < 2) {
555
+ return false;
556
+ }
557
+
558
+ for (var i = 0; i < parts.length; i++) {
559
+ if (parts[i] === "") {
560
+ return false;
561
+ }
562
+ }
563
+
564
+ var domain = parts.pop();
565
+ var domainParts = domain.split(".");
566
+ var tld = "";
567
+
568
+ if (domainParts.length == 0) {
569
+ // The address does not have a top-level domain
570
+ return false;
571
+ } else if (domainParts.length == 1) {
572
+ // The address has only a top-level domain (valid under RFC)
573
+ tld = domainParts[0];
574
+ } else {
575
+ // The address has a domain and a top-level domain
576
+ for (var i = 1; i < domainParts.length; i++) {
577
+ tld += domainParts[i] + ".";
578
+ }
579
+ if (domainParts.length >= 2) {
580
+ tld = tld.substring(0, tld.length - 1);
581
+ }
582
+ }
583
+
584
+ return {
585
+ topLevelDomain: tld,
586
+ domain: domain,
587
+ address: parts.join("@")
588
+ }
589
+ },
590
+
591
+ // Encode the email address to prevent XSS but leave in valid
592
+ // characters, following this official spec:
593
+ // http://en.wikipedia.org/wiki/Email_address#Syntax
594
+ encodeEmail: function(email) {
595
+ var result = encodeURI(email);
596
+ result = result.replace("%20", " ").replace("%25", "%").replace("%5E", "^")
597
+ .replace("%60", "`").replace("%7B", "{").replace("%7C", "|")
598
+ .replace("%7D", "}");
599
+ return result;
600
+ }
601
+ };
602
+
603
+ // Export the mailcheck object if we"re in a CommonJS env (e.g. Node).
604
+ // Modeled off of Underscore.js.
605
+ if (typeof module !== "undefined" && module.exports) {
606
+ module.exports = Mailcheck;
607
+ }
608
 
609
+ if (typeof window !== "undefined" && window.jQuery) {
610
+ (function($){
611
+ $.fn.mailcheck = function(opts) {
612
+ var self = this;
613
+ if (opts.suggested) {
614
+ var oldSuggested = opts.suggested;
615
+ opts.suggested = function(result) {
616
+ oldSuggested(self, result);
617
+ };
618
+ }
619
+
620
+ if (opts.empty) {
621
+ var oldEmpty = opts.empty;
622
+ opts.empty = function() {
623
+ oldEmpty.call(null, self);
624
+ };
625
+ }
626
+
627
+ opts.email = this.val();
628
+ Mailcheck.run(opts);
629
+ }
630
+ })(jQuery);
631
+ };
632
+ }
633
+ jQuery(document).ready(function($){
634
 
635
  jQuery("form").submit(function(e) {
636
  jQuery(this).find("input").each(function(){
643
  }
644
  });
645
  });
646
+ $(".inbound-email").on("blur", function(event) {
647
+ //console.log("event ", event);
648
+ //console.log("this ", $(this));
649
+ var that = $(this);
650
+ $(this).mailcheck({
651
+
652
+ suggested: function(element, suggestion) {
653
+ // callback code
654
+ console.log("suggestion ", suggestion.full);
655
+ $(".email_suggestion").remove();
656
+ var insert = "<span class=\"email_suggestion\">Did you mean <b><i>" + suggestion.full + "</b></i>?</span>";
657
+ $(that).after(insert);
658
+ },
659
+ empty: function(element) {
660
+ // callback code
661
+ $(".email_suggestion").html("No Suggestions :(");
662
+ }
663
+ });
664
+ });
665
  jQuery("#inbound_form_submit br").remove(); // remove br tags
666
  function validateEmail(email) {
667
 
675
  // validate email
676
  $("input.inbound-email").on("change keyup", function (e) {
677
  var email = $(this).val();
678
+ $(".email_suggestion").remove();
679
  if (validateEmail(email)) {
680
  $(this).css("color", "green");
681
  $(this).addClass("valid-email");
695
 
696
  echo "<style type='text/css'>
697
  /* Add button style options http://medleyweb.com/freebies/50-super-sleek-css-button-style-snippets/ */
698
+ .email_suggestion {
699
+ font-size: 13px;
700
+ padding-top: 0px;
701
+ margin-top: 0px;
702
+ display: block;
703
+ font-style: italic;
704
+ }
705
  input.invalid-email {-webkit-box-shadow: 0 0 6px #F8B9B7;
706
  -moz-box-shadow: 0 0 6px #f8b9b7;
707
  box-shadow: 0 0 6px #F8B9B7;
805
  $field = "wpleads_work_phone";
806
  }
807
 
808
+ $form_post_data[$field] = (!is_array($value)) ? strip_tags( $value ) : $value;
809
+
810
  }
811
 
812
  $form_meta_data['post_id'] = $_POST['inbound_form_id']; // pass in form id
813
+
814
  /* Send emails if passes spam check returns false */
815
  if ( !apply_filters( 'inbound_check_if_spam' , false , $form_post_data ) ) {
816
  self::send_conversion_admin_notification($form_post_data , $form_meta_data);
851
  if ( !isset($form_meta_data['inbound_notify_email']) ) {
852
  return;
853
  }
854
+
855
  /* Get Email We Should Send Notifications To */
856
  $email_to = $form_meta_data['inbound_notify_email'];
857
 
976
 
977
 
978
  $confirm_subject = $Inbound_Templating_Engine->replace_tokens( $confirm_subject, array($form_post_data, $form_meta_data ));
979
+
980
  /* add default subject if empty */
981
  if (!$confirm_subject) {
982
  $confirm_subject = __( 'Thank you!' , 'leads' );
983
  }
984
+
985
  $confirm_email_message = $Inbound_Templating_Engine->replace_tokens( $confirm_email_message , array( $form_post_data, $form_meta_data ) );
986
 
987
 
shared/classes/class.post-type.email-template.php CHANGED
@@ -63,6 +63,10 @@ if ( !class_exists('Inbound_Email_Templates_Post_Type') ) {
63
  'parent_item_colon' => ''
64
  );
65
 
 
 
 
 
66
  $args = array(
67
  'labels' => $labels,
68
  'public' => true,
@@ -70,7 +74,7 @@ if ( !class_exists('Inbound_Email_Templates_Post_Type') ) {
70
  'show_ui' => true,
71
  'query_var' => true,
72
  //'menu_icon' => INBOUDNOW_SHARED_URLPATH . '/images/email.png',
73
- 'show_in_menu' => 'edit.php?post_type=wp-lead',
74
  'capability_type' => 'post',
75
  'hierarchical' => false,
76
  'menu_position' => null,
63
  'parent_item_colon' => ''
64
  );
65
 
66
+ /* Menu to place email templates sub menu into */
67
+ $labels = apply_filters( 'inbound_email-template_labels' , $labels );
68
+ $post_type = apply_filters( 'inbound_email-template_submenu_placement' , 'wp-lead' );
69
+
70
  $args = array(
71
  'labels' => $labels,
72
  'public' => true,
74
  'show_ui' => true,
75
  'query_var' => true,
76
  //'menu_icon' => INBOUDNOW_SHARED_URLPATH . '/images/email.png',
77
+ 'show_in_menu' => 'edit.php?post_type=' . $post_type ,
78
  'capability_type' => 'post',
79
  'hierarchical' => false,
80
  'menu_position' => null,
shared/classes/class.post-type.wp-lead.php CHANGED
@@ -6,7 +6,7 @@ if ( !class_exists('Inbound_Leads') ) {
6
  class Inbound_Leads {
7
 
8
  /**
9
- * Initalize Inbound_Leads class
10
  */
11
  function __construct() {
12
  self::load_hooks();
6
  class Inbound_Leads {
7
 
8
  /**
9
+ * Initialize Inbound_Leads class
10
  */
11
  function __construct() {
12
  self::load_hooks();
shared/classes/class.shortcodes.email-template.php CHANGED
@@ -18,6 +18,7 @@ class Inbound_Email_Template_Shortcodes {
18
  add_shortcode( 'inbound-gravitar', array( __CLASS__, 'generate_gravitar' ), 1 );
19
  }
20
 
 
21
  /**
22
  * Used by leads-new-lead-notification email template to dispaly form fields the user inputted when converting on a form.
23
  *
@@ -47,6 +48,14 @@ class Inbound_Email_Template_Shortcodes {
47
  }
48
  }
49
 
 
 
 
 
 
 
 
 
50
  foreach ($post_params as $key => $value ) {
51
 
52
  $name = str_replace(array('-','_'),' ', $key);
@@ -56,13 +65,14 @@ class Inbound_Email_Template_Shortcodes {
56
  continue;
57
  }
58
 
59
-
60
  if (is_array($value)) {
61
  $value = implode(', ', $value);
62
  } else if ( strlen($value) < 1 ) {
63
  $value = __( 'n/a' , 'ma');
64
  }
65
 
 
66
  /* Rewrite UTM params */
67
  if (preg_match( '/utm_/i', $key)) {
68
  $name = ucfirst(str_replace("utm_", "", $key));
@@ -93,16 +103,20 @@ class Inbound_Email_Template_Shortcodes {
93
  $name = __("Converted on Page" , 'ma' );
94
  }
95
 
96
- $html .= '<tr style="border-bottom:1px solid #cccccc;">';
97
- $html .= '<td width="600" style="border-right:1px solid #cccccc;padding:10px;padding-bottom:5px;">';
98
- $html .= '<div style="padding-left:5px;display:inline-block;padding-bottom:5px;font-size: 16px; color:#555;"><strong>';
99
- $html .= $name;
100
- $html .= '</strong></div><div style="padding-left:5px;display:inline-block;font-size:14px;color:#000;">';
101
- $html .= $value;
102
- $html .= '</div></td></tr>';
 
 
 
103
  }
104
 
105
-
 
106
  return $html;
107
  }
108
 
@@ -127,4 +141,4 @@ class Inbound_Email_Template_Shortcodes {
127
  /* Initiate the logging system */
128
  $Inbound_Email_Template_Shortcodes = new Inbound_Email_Template_Shortcodes();
129
 
130
- }
18
  add_shortcode( 'inbound-gravitar', array( __CLASS__, 'generate_gravitar' ), 1 );
19
  }
20
 
21
+
22
  /**
23
  * Used by leads-new-lead-notification email template to dispaly form fields the user inputted when converting on a form.
24
  *
48
  }
49
  }
50
 
51
+ if( isset($post_params[ 'email' ])){
52
+ $emailVal = $post_params[ 'email' ];
53
+ unset($post_params[ 'email' ]);
54
+ $email_array = array('email' => $emailVal );
55
+ $post_params = array_merge( $email_array, $post_params );
56
+ //print_r($post_params); exit;
57
+ }
58
+
59
  foreach ($post_params as $key => $value ) {
60
 
61
  $name = str_replace(array('-','_'),' ', $key);
65
  continue;
66
  }
67
 
68
+
69
  if (is_array($value)) {
70
  $value = implode(', ', $value);
71
  } else if ( strlen($value) < 1 ) {
72
  $value = __( 'n/a' , 'ma');
73
  }
74
 
75
+
76
  /* Rewrite UTM params */
77
  if (preg_match( '/utm_/i', $key)) {
78
  $name = ucfirst(str_replace("utm_", "", $key));
103
  $name = __("Converted on Page" , 'ma' );
104
  }
105
 
106
+ $html .= '<tr style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#cccccc;">';
107
+ $html .= '<td width="600" style="border-right:1px solid #cccccc;">';
108
+ //$html .= '<div style="padding-left:5px;display:inline-block;padding-bottom:5px;font-size:16px;color:#555;font-weight:bold;">' . $name . '</div>';
109
+ $html .= '<table cellpadding="10" style="width:100%;max-width:600px;border-collapse:collapse;border:none;background:white;"><tbody><tr style="background:#ffffff;height:27px;font-weight:lighter;color:#555;font-size:16px;border:none;text-align:left;"><td align="left" width="200" style="color:#555;font-size:16px;font-weight:bold;">';
110
+ $html .= $name;
111
+ $html .= '</td><td align="left" width="400" style="font-size:14px;color:#000;">';
112
+ $html .= $value;
113
+ $html .= '</td></tr></tbody></table>';
114
+ //$html .= '<div style="padding-left:5px;display:inline-block;font-size:14px;color:#000;">'. $value .'</div>';
115
+ $html .= '</td></tr>';
116
  }
117
 
118
+ //echo $html; exit;
119
+
120
  return $html;
121
  }
122
 
141
  /* Initiate the logging system */
142
  $Inbound_Email_Template_Shortcodes = new Inbound_Email_Template_Shortcodes();
143
 
144
+ }
shared/metaboxes/inbound-metaboxes.css CHANGED
@@ -1,6 +1,7 @@
1
  #inbound-meta .inbound-meta-box-row {
2
  display: block;
3
- padding-bottom: 10px;
 
4
  }
5
  .inbound-meta-box-label, .inbound-meta-box-option {
6
  display: inline-block;
@@ -30,12 +31,6 @@ top: 0px;
30
  text-align: center;
31
  width: 84px;
32
  }
33
- .inbound-meta-box-option.inbound-text-option, .inbound-meta-box-option.inbound-text-option input[type=text] {
34
- width:80%;
35
- }
36
- .inbound-meta-box-option.inbound-text-option input[type=text].cta-width, .inbound-meta-box-option.inbound-text-option input[type=text].cta-height {
37
- width: 100px;
38
- }
39
  #inbound-meta .inbound-custom-css-row {
40
  padding: 0px;
41
  }
@@ -59,7 +54,7 @@ display: inline-block;
59
  }
60
  .inbound-wysiwyg, .inbound-media, .inbound-datepicker, .inbound-textarea {
61
  vertical-align: top;
62
- }
63
  .inbound-textarea-option .wp-cta-success-message {
64
  position: absolute;
65
  margin-top: 0px;
1
  #inbound-meta .inbound-meta-box-row {
2
  display: block;
3
+ padding: 10px;
4
+ padding-left: 0px;
5
  }
6
  .inbound-meta-box-label, .inbound-meta-box-option {
7
  display: inline-block;
31
  text-align: center;
32
  width: 84px;
33
  }
 
 
 
 
 
 
34
  #inbound-meta .inbound-custom-css-row {
35
  padding: 0px;
36
  }
54
  }
55
  .inbound-wysiwyg, .inbound-media, .inbound-datepicker, .inbound-textarea {
56
  vertical-align: top;
57
+ }
58
  .inbound-textarea-option .wp-cta-success-message {
59
  position: absolute;
60
  margin-top: 0px;
shared/shortcodes/inbound-shortcodes.php CHANGED
@@ -584,8 +584,7 @@ class Inbound_Shortcodes {
584
  $column_css = "#inbound-list.class-".$num." ul { clear:both;} #inbound-list.class-".$num." li { width: 19.5%; float: left; display: inline;}";
585
  }
586
 
587
- return '<style type="text/css">
588
-
589
  #inbound-list.class-'.$num.' li {
590
  '.$final_text_color.'
591
  list-style: none;
@@ -612,10 +611,7 @@ class Inbound_Shortcodes {
612
  width:100%;
613
  }
614
  }
615
- </style>
616
- <div id="inbound-list" class="inbound-list class-'.$num.' fa-list-'.$icon.'">
617
- '. do_shortcode($content).'
618
- </div>';
619
  }
620
 
621
  static function inbound_forms_header_area()
584
  $column_css = "#inbound-list.class-".$num." ul { clear:both;} #inbound-list.class-".$num." li { width: 19.5%; float: left; display: inline;}";
585
  }
586
 
587
+ return '<div id="inbound-list" class="inbound-list class-'.$num.' fa-list-'.$icon.'">'. do_shortcode($content).'</div>' . '<style type="text/css">
 
588
  #inbound-list.class-'.$num.' li {
589
  '.$final_text_color.'
590
  list-style: none;
611
  width:100%;
612
  }
613
  }
614
+ </style>';
 
 
 
615
  }
616
 
617
  static function inbound_forms_header_area()
shared/shortcodes/shortcodes/forms.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Inbound Forms Shortcode Options
4
  * Forms code found in /shared/classes/form.class.php
 
5
  */
6
 
7
  if (empty($lead_list_names)){
@@ -273,7 +274,7 @@
273
  ),
274
  'helper' => array(
275
  'name' => __('Field Description <span class="small-optional-text">(optional)</span>', 'leads'),
276
- 'desc' => __('<span class="show-advanced-fields">▶ Show advanced fields</span>', 'leads'),
277
  'type' => 'helper-block',
278
  'std' => '',
279
  'class' => '',
2
  /**
3
  * Inbound Forms Shortcode Options
4
  * Forms code found in /shared/classes/form.class.php
5
+ * master code
6
  */
7
 
8
  if (empty($lead_list_names)){
274
  ),
275
  'helper' => array(
276
  'name' => __('Field Description <span class="small-optional-text">(optional)</span>', 'leads'),
277
+ 'desc' => __('<span class="show-advanced-fields">Show advanced fields</span>', 'leads'),
278
  'type' => 'helper-block',
279
  'std' => '',
280
  'class' => '',
shared/shortcodes/shortcodes/lists.php CHANGED
@@ -13,7 +13,7 @@
13
  'desc' => __('Select an icon for the List', 'leads'),
14
  'type' => 'select',
15
  'options' => $fontawesome,
16
- 'std' => 'ok-sign'
17
  ),
18
  'font-size' => array(
19
  'name' => __('Font Size', 'leads'),
13
  'desc' => __('Select an icon for the List', 'leads'),
14
  'type' => 'select',
15
  'options' => $fontawesome,
16
+ 'std' => 'check'
17
  ),
18
  'font-size' => array(
19
  'name' => __('Font Size', 'leads'),
shared/templates/email-templates/token-test/token-test.php CHANGED
@@ -2,54 +2,54 @@
2
 
3
  $inbound_email_templates['token-test'] = '
4
 
5
- <h2>'. __( 'Core Tokens', 'ma' ) .'</h2>
6
- <p>'. __( 'Admin Email Address' , 'ma' ) .':{{admin-email-address}}</p>
7
- <p>'. __( 'Site Name' , 'ma' ) .':{{site-name}}</p>
8
- <p>'. __( 'Site Url' , 'ma' ) .':{{site-url}}</p>
9
- <p>'. __( 'Date-time' , 'ma' ) .': {{date-time}}</p>
10
- <p>'. __( 'Leads URL Path' , 'ma' ) .': {{leads-urlpath}}</p>
11
- <p>'. __( 'Landing Pages URL Path' , 'ma' ) .': {{landingpages-urlpath}}</p>
12
-
13
- <h2>'. __( 'Lead Tokens' , 'ma' ) .'</h2>
14
- <p>'. __( 'First Name' , 'ma' ) .': {{lead-first-name}}</p>
15
- <p>'. __( 'Last Name' , 'ma' ) .':{{lead-last-name}}</p>
16
- <p>'. __( 'Email' , 'ma' ) .': {{lead-email-address}}</p>
17
- <p>'. __( 'Company Name' , 'ma' ) .': {{lead-company-name}}</p>
18
- <p>'. __( 'Address Line 1' , 'ma' ) .': {{lead-address-line-1}}</p>
19
- <p>'. __( 'Address Line 2' , 'ma' ) .': {{lead-address-line-2}}</p>
20
- <p>'. __( 'City' , 'ma' ) .': {{lead-city}}</p>
21
- <p>'. __( 'Region/State' , 'ma' ) .': {{lead-region}}</p>
22
- <p>'. __( 'Form Name' , 'ma' ) .':{{form-name}}</p>
23
- <p>'. __( 'Converted Page URL' , 'ma' ) .': {{source}}</p>
24
-
25
- <h2>'. __( 'WP User Tokens' , 'ma' ) .'</h2>
26
- <p>'. __( 'WordPress User ID' , 'ma' ) .': {{wp-user-id}}</p>
27
- <p>'. __( 'WordPress User Username' , 'ma' ) .': {{wp-user-username}}</p>
28
- <p>'. __( 'WordPress User First Name' , 'ma' ) .': {{wp-user-first-name}}</p>
29
- <p>'. __( 'WordPress User Last Name' , 'ma' ) .': {{wp-user-last-name}}</p>
30
- <p>'. __( 'WordPress User Password' , 'ma' ) .': {{wp-user-password}}</p>
31
- <p>'. __( 'WordPress User Nicename' , 'ma' ) .': {{wp-user-nicename}}</p>
32
- <p>'. __( 'WordPress User Display Name' , 'ma' ) .': {{wp-user-displayname}}</p>
33
- <p>'. __( 'WordPress User Gravatar URL' , 'ma' ) .': {{wp-user-gravatar-url}}</p>
34
-
35
-
36
- <h2>'. __( 'WP Post Tokens' , 'ma' ) .'</h2>
37
- <p>'. __( 'WordPress Post ID' , 'ma' ) .': {{wp-post-id}}</p>
38
- <p>'. __( 'WordPress Post Title' , 'ma' ) .': {{wp-post-title}}</p>
39
- <p>'. __( 'WordPress Post URL' , 'ma' ) .': {{wp-post-url}}</p>
40
- <p>'. __( 'WordPress Post Content' , 'ma' ) .': {{wp-post-content}}</p>
41
- <p>'. __( 'WordPress Post Excerpt' , 'ma' ) .': {{wp-post-excerpt}}</p>
42
-
43
-
44
- <h2>'. __( 'WP Comment Tokens' , 'ma' ) .'</h2>
45
- <p>'. __( 'WordPress Comment ID' , 'ma' ) .': {{wp-comment-id}}</p>
46
- <p>'. __( 'WordPress Comment URL' , 'ma' ) .': {{wp-comment-url}}</p>
47
- <p>'. __( 'WordPress Comment Author' , 'ma' ) .': {{wp-comment-author}}</p>
48
- <p>'. __( 'WordPress Comment Author Email' , 'ma' ) .': {{wp-comment-author-email}}</p>
49
- <p>'. __( 'WordPress Comment Author IP' , 'ma' ) .': {{wp-comment-author-ip}}</p>
50
- <p>'. __( 'WordPress Comment Content' , 'ma' ) .': {{wp-comment-content}}</p>
51
- <p>'. __( 'WordPress Comment Date' , 'ma' ) .': {{wp-comment-date}}</p>
52
- <p>'. __( 'WordPress Comment Karma' , 'ma' ) .': {{wp-comment-karma}}</p>
53
 
54
 
55
  ';
2
 
3
  $inbound_email_templates['token-test'] = '
4
 
5
+ <h2>'. __( 'Core Tokens', 'leads' ) .'</h2>
6
+ <p>'. __( 'Admin Email Address' , 'leads' ) .':{{admin-email-address}}</p>
7
+ <p>'. __( 'Site Name' , 'leads' ) .':{{site-name}}</p>
8
+ <p>'. __( 'Site Url' , 'leads' ) .':{{site-url}}</p>
9
+ <p>'. __( 'Date-time' , 'leads' ) .': {{date-time}}</p>
10
+ <p>'. __( 'Leads URL Path' , 'leads' ) .': {{leads-urlpath}}</p>
11
+ <p>'. __( 'Landing Pages URL Path' , 'leads' ) .': {{landingpages-urlpath}}</p>
12
+
13
+ <h2>'. __( 'Lead Tokens' , 'leads' ) .'</h2>
14
+ <p>'. __( 'First Name' , 'leads' ) .': {{lead-first-name}}</p>
15
+ <p>'. __( 'Last Name' , 'leads' ) .':{{lead-last-name}}</p>
16
+ <p>'. __( 'Email' , 'leads' ) .': {{lead-email-address}}</p>
17
+ <p>'. __( 'Company Name' , 'leads' ) .': {{lead-company-name}}</p>
18
+ <p>'. __( 'Address Line 1' , 'leads' ) .': {{lead-address-line-1}}</p>
19
+ <p>'. __( 'Address Line 2' , 'leads' ) .': {{lead-address-line-2}}</p>
20
+ <p>'. __( 'City' , 'leads' ) .': {{lead-city}}</p>
21
+ <p>'. __( 'State/Region' , 'leads' ) .': {{lead-region}}</p>
22
+ <p>'. __( 'Form Name' , 'leads' ) .':{{form-name}}</p>
23
+ <p>'. __( 'Converted Page URL' , 'leads' ) .': {{source}}</p>
24
+
25
+ <h2>'. __( 'WP User Tokens' , 'leads' ) .'</h2>
26
+ <p>'. __( 'WordPress User ID' , 'leads' ) .': {{wp-user-id}}</p>
27
+ <p>'. __( 'WordPress User Username' , 'leads' ) .': {{wp-user-username}}</p>
28
+ <p>'. __( 'WordPress User First Name' , 'leads' ) .': {{wp-user-first-name}}</p>
29
+ <p>'. __( 'WordPress User Last Name' , 'leads' ) .': {{wp-user-last-name}}</p>
30
+ <p>'. __( 'WordPress User Password' , 'leads' ) .': {{wp-user-password}}</p>
31
+ <p>'. __( 'WordPress User Nicename' , 'leads' ) .': {{wp-user-nicename}}</p>
32
+ <p>'. __( 'WordPress User Display Name' , 'leads' ) .': {{wp-user-displayname}}</p>
33
+ <p>'. __( 'WordPress User Gravatar URL' , 'leads' ) .': {{wp-user-gravatar-url}}</p>
34
+
35
+
36
+ <h2>'. __( 'WP Post Tokens' , 'leads' ) .'</h2>
37
+ <p>'. __( 'WordPress Post ID' , 'leads' ) .': {{wp-post-id}}</p>
38
+ <p>'. __( 'WordPress Post Title' , 'leads' ) .': {{wp-post-title}}</p>
39
+ <p>'. __( 'WordPress Post URL' , 'leads' ) .': {{wp-post-url}}</p>
40
+ <p>'. __( 'WordPress Post Content' , 'leads' ) .': {{wp-post-content}}</p>
41
+ <p>'. __( 'WordPress Post Excerpt' , 'leads' ) .': {{wp-post-excerpt}}</p>
42
+
43
+
44
+ <h2>'. __( 'WP Comment Tokens' , 'leads' ) .'</h2>
45
+ <p>'. __( 'WordPress Comment ID' , 'leads' ) .': {{wp-comment-id}}</p>
46
+ <p>'. __( 'WordPress Comment URL' , 'leads' ) .': {{wp-comment-url}}</p>
47
+ <p>'. __( 'WordPress Comment Author' , 'leads' ) .': {{wp-comment-author}}</p>
48
+ <p>'. __( 'WordPress Comment Author Email' , 'leads' ) .': {{wp-comment-author-email}}</p>
49
+ <p>'. __( 'WordPress Comment Author IP' , 'leads' ) .': {{wp-comment-author-ip}}</p>
50
+ <p>'. __( 'WordPress Comment Content' , 'leads' ) .': {{wp-comment-content}}</p>
51
+ <p>'. __( 'WordPress Comment Date' , 'leads' ) .': {{wp-comment-date}}</p>
52
+ <p>'. __( 'WordPress Comment Karma' , 'leads' ) .': {{wp-comment-karma}}</p>
53
 
54
 
55
  ';
shared/templates/email-templates/wp-notify-moderator/wp-notify-moderator.php CHANGED
@@ -30,8 +30,8 @@ $inbound_email_templates['wp-notify-moderator'] = '<!DOCTYPE html PUBLIC "-//W3C
30
  <tbody><tr>
31
  <td valign="top" style="font-size:13px;line-height:20px;color:#545454;font-family:Arial,sans-serif;border-radius:0 0 3px 3px;padding-top:3px;padding-right:30px;padding-bottom:15px;padding-left:30px">
32
 
33
- <h1 style="margin-top:20px;margin-right:0;margin-bottom:20px;margin-left:0; font-size:28px; line-height: 28px; color:#000;">'. __( 'New Comment Waiting Moderation' , 'ma' ) .'</h1>
34
- <p style="margin-top:20px;margin-right:0;margin-bottom:20px;margin-left:0">'. __( '{{wp-user-displayname}}, There is a new comment on <a href="{{wp-post-url}}">{{wp-post-title}}</a>' , 'ma' ) .' awaiting your response.</p>
35
 
36
  <!-- NEW TABLE -->
37
  <table class="heavyTable" style="width: 100%;
@@ -45,10 +45,10 @@ $inbound_email_templates['wp-notify-moderator'] = '<!DOCTYPE html PUBLIC "-//W3C
45
  <tr style="border-bottom: 1px solid #cccccc;">
46
  <td width="600" style="border-right: 1px solid #cccccc; padding: 10px; padding-bottom: 5px;">
47
  <div style="padding-left:5px; display:inline-block; padding-bottom: 5px; font-size: 16px; color:#555;">
48
- <strong>{{wp-comment-author}} '. __( 'says:' , 'ma' ) .'</strong><br>
49
  {{wp-comment-content}} <br><br>
50
 
51
- <a href="{{wp-comment-url}}">'. __('Click here to reply' , 'ma') .'</a>
52
  </div>
53
 
54
  </td>
@@ -65,19 +65,19 @@ $inbound_email_templates['wp-notify-moderator'] = '<!DOCTYPE html PUBLIC "-//W3C
65
  <tbody valign="top">
66
  <tr valign="top" border="0">
67
  <td width="120" height="50" align="center" valign="top" border="0">
68
- <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=approve&c={{wp-comment-id}}">'. __( 'Approve' , 'ma' ) .'</a></h3>
69
  </td>
70
 
71
  <td width="120" height="50" align="center" valign="top" border="0">
72
- <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=trash&c={{wp-comment-id}}">'. __( 'Trash' , 'ma' ) .'</a></h3>
73
  </td>
74
 
75
  <td width="120" height="50" align="center" valign="top" border="0">
76
- <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=delete&c={{wp-comment-id}}">'. __( 'Delete' , 'ma' ) .'</a></h3>
77
  </td>
78
 
79
  <td width="120" height="50" align="center" valign="top" border="0">
80
- <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=spam&c={{wp-comment-id}}">'. __( 'Spam' , 'ma' ) .'</a></h3>
81
  </td>
82
  </tr>
83
  </tbody></table>
30
  <tbody><tr>
31
  <td valign="top" style="font-size:13px;line-height:20px;color:#545454;font-family:Arial,sans-serif;border-radius:0 0 3px 3px;padding-top:3px;padding-right:30px;padding-bottom:15px;padding-left:30px">
32
 
33
+ <h1 style="margin-top:20px;margin-right:0;margin-bottom:20px;margin-left:0; font-size:28px; line-height: 28px; color:#000;">'. __( 'New Comment Waiting Moderation' , 'leads' ) .'</h1>
34
+ <p style="margin-top:20px;margin-right:0;margin-bottom:20px;margin-left:0">'. __( '{{wp-user-displayname}}, There is a new comment for <a href="{{wp-post-url}}">{{wp-post-title}}</a>' , 'leads' ) .' awaiting your response.</p>
35
 
36
  <!-- NEW TABLE -->
37
  <table class="heavyTable" style="width: 100%;
45
  <tr style="border-bottom: 1px solid #cccccc;">
46
  <td width="600" style="border-right: 1px solid #cccccc; padding: 10px; padding-bottom: 5px;">
47
  <div style="padding-left:5px; display:inline-block; padding-bottom: 5px; font-size: 16px; color:#555;">
48
+ <strong>{{wp-comment-author}} '. __( 'says:' , 'leads' ) .'</strong><br>
49
  {{wp-comment-content}} <br><br>
50
 
51
+ <a href="{{wp-comment-url}}">'. __('Click here to reply' , 'leads') .'</a>
52
  </div>
53
 
54
  </td>
65
  <tbody valign="top">
66
  <tr valign="top" border="0">
67
  <td width="120" height="50" align="center" valign="top" border="0">
68
+ <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=approve&c={{wp-comment-id}}">'. __( 'Approve' , 'leads' ) .'</a></h3>
69
  </td>
70
 
71
  <td width="120" height="50" align="center" valign="top" border="0">
72
+ <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=trash&c={{wp-comment-id}}">'. __( 'Trash' , 'leads' ) .'</a></h3>
73
  </td>
74
 
75
  <td width="120" height="50" align="center" valign="top" border="0">
76
+ <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=delete&c={{wp-comment-id}}">'. __( 'Delete' , 'leads' ) .'</a></h3>
77
  </td>
78
 
79
  <td width="120" height="50" align="center" valign="top" border="0">
80
+ <h3 style="color:#2e2e2e;font-size:15px;"><a style="text-decoration: none;" href="{{admin-url}}comment.php?action=spam&c={{wp-comment-id}}">'. __( 'Spam' , 'leads' ) .'</a></h3>
81
  </td>
82
  </tr>
83
  </tbody></table>
shared/tracking/store.lead.php CHANGED
@@ -36,7 +36,7 @@ function inbound_store_lead_search($args = array()) {
36
  $search_array = array();
37
  foreach ($search as $key => $value) {
38
  $search_array[$count] = array( 'date' => $search[$count]['date'],
39
- 'value' => $search[$count]['value']);
40
  $count++;
41
  }
42
 
@@ -75,9 +75,9 @@ add_action('wp_ajax_inbound_store_lead', 'inbound_store_lead' , 10 , 1);
75
  add_action('wp_ajax_nopriv_inbound_store_lead', 'inbound_store_lead' ,10 , 1);
76
 
77
  /**
78
- * This method needs to be rebuilt
79
  */
80
- function inbound_store_lead( $args = array( ) ) {
81
  global $user_ID, $wpdb;
82
 
83
  if (!is_array($args)) {
@@ -92,7 +92,7 @@ function inbound_store_lead( $args = array( ) ) {
92
  $lead_data['user_ID'] = $user_ID;
93
  $lead_data['wordpress_date_time'] = date("Y-m-d G:i:s T", $time);
94
  $lead_data['wpleads_email_address'] = (isset($args['emailTo'])) ? $args['emailTo'] : false;
95
- $lead_data['page_views'] = (isset($args['page_views'])) ? $args['page_views'] : false;
96
  $lead_data['form_input_values'] = (isset($args['form_input_values'])) ? $args['form_input_values'] : false; // raw post data
97
 
98
  /* Attempt to populate lead data through mappped fields */
@@ -105,7 +105,7 @@ function inbound_store_lead( $args = array( ) ) {
105
  $lead_data['post_type'] = (array_key_exists('post_type', $mapped_data)) ? $mapped_data['post_type'] : false;
106
  $lead_data['wp_lead_uid'] = (array_key_exists('wp_lead_uid', $mapped_data)) ? $mapped_data['wp_lead_uid'] : false;
107
  $lead_data['lead_lists'] = (array_key_exists('leads_list', $mapped_data)) ? explode(",", $mapped_data['leads_list']) : false;
108
- $lead_data['ip_address'] = (array_key_exists('ip_address', $mapped_data)) ? $mapped_data['ip_address'] : false;
109
 
110
 
111
  /* Check first level for data related to lead submit */
@@ -119,8 +119,8 @@ function inbound_store_lead( $args = array( ) ) {
119
  $lead_data['search_data'] = $search_data;
120
 
121
  /* Legacy - needs to be phased out - search for alias key matches */
122
- $lead_data['wpleads_full_name'] = (isset($args['full_name'])) ? $args['full_name'] : "";
123
- $lead_data['wpleads_first_name'] = (isset($args['first_name'])) ? $args['first_name'] : "";
124
  $lead_data['wpleads_last_name'] = (isset($args['last_name'])) ? $args['last_name'] : "";
125
  $lead_data['wpleads_company_name'] = (isset($args['company_name'] )) ? $args['company_name'] : "";
126
  $lead_data['wpleads_mobile_phone'] = (isset($args['phone'])) ? $args['phone'] : "";
@@ -136,7 +136,7 @@ function inbound_store_lead( $args = array( ) ) {
136
  do_action('inbound_store_lead_pre' , $lead_data , $args ); // Global lead storage action hook
137
 
138
  /* bail if spam */
139
- if (apply_filters( 'inbound_check_if_spam' , false , $lead_data )) {
140
  exit;
141
  }
142
 
@@ -165,7 +165,7 @@ function inbound_store_lead( $args = array( ) ) {
165
  /* Create New Lead */
166
  $post = array(
167
  'post_title' => $lead_data['wpleads_email_address'],
168
- //'post_content' => $json,
169
  'post_status' => 'publish',
170
  'post_type' => 'wp-lead',
171
  'post_author' => 1
@@ -174,7 +174,6 @@ function inbound_store_lead( $args = array( ) ) {
174
  //$post = add_filter('lp_leads_post_vars',$post);
175
  $lead_data['lead_id'] = wp_insert_post($post);
176
  $lead_id = $lead_data['lead_id'];
177
- update_post_meta( $lead_id, 'wpleads_wordpress_user_id', $user_ID );
178
 
179
  /* updates common meta for new leads */
180
  inbound_update_common_meta($lead_data);
@@ -188,8 +187,8 @@ function inbound_store_lead( $args = array( ) ) {
188
  }
189
 
190
  /***
191
- * Run Processes for all Leads below
192
- ***/
193
  do_action('wpleads_after_conversion_lead_insert',$lead_id); // action hook on all lead inserts
194
 
195
  update_post_meta( $lead_id, 'wpleads_inbound_form_mapped_data', $lead_data['Mapped_Data']);
@@ -229,20 +228,7 @@ function inbound_store_lead( $args = array( ) ) {
229
 
230
  /* Store IP addresss & Store GEO Data */
231
  if ($lead_data['ip_address']) {
232
- update_post_meta( $lead_id, 'wpleads_ip_address', $lead_data['ip_address'] );
233
- if ($lead_data['ip_address'] != "127.0.0.1"){ // exclude localhost
234
- $geo_array = @unserialize(wp_remote_get('http://www.geoplugin.net/php.gp?ip='.$lead_data['ip_address']));
235
- (isset($geo_array['geoplugin_areaCode'])) ? update_post_meta( $lead_id, 'wpleads_areaCode', $geo_array['geoplugin_areaCode'] ) : null;
236
- (isset($geo_array['geoplugin_city'])) ? update_post_meta( $lead_id, 'wpleads_city', $geo_array['geoplugin_city'] ) : null;
237
- (isset($geo_array['geoplugin_regionName'])) ? update_post_meta( $lead_id, 'wpleads_region_name', $geo_array['geoplugin_regionName'] ) : null;
238
- (isset($geo_array['geoplugin_regionCode'])) ? update_post_meta( $lead_id, 'wpleads_region_code', $geo_array['geoplugin_regionCode'] ) : null;
239
- (isset($geo_array['geoplugin_countryName'])) ? update_post_meta( $lead_id, 'wpleads_country_name', $geo_array['geoplugin_countryName'] ) : null;
240
- (isset($geo_array['geoplugin_countryCode'])) ? update_post_meta( $lead_id, 'wpleads_country_code', $geo_array['geoplugin_countryCode'] ) : null;
241
- (isset($geo_array['geoplugin_latitude'])) ? update_post_meta( $lead_id, 'wpleads_latitude', $geo_array['geoplugin_latitude'] ) : null;
242
- (isset($geo_array['geoplugin_longitude'])) ? update_post_meta( $lead_id, 'wpleads_longitude', $geo_array['geoplugin_longitude'] ) : null;
243
- (isset($geo_array['geoplugin_currencyCode'])) ? update_post_meta( $lead_id, 'wpleads_currency_code', $geo_array['geoplugin_currencyCode'] ) : null;
244
- (isset($geo_array['geoplugin_currencySymbol_UTF8'])) ? update_post_meta( $lead_id, 'wpleads_currency_symbol', $geo_array['geoplugin_currencySymbol_UTF8'] ) : null;
245
- }
246
  }
247
 
248
  /* Store Conversion Data to Lead */
@@ -264,7 +250,7 @@ function inbound_store_lead( $args = array( ) ) {
264
  update_post_meta($lead_id, 'wpleads_referral_data', $lead_data['referral_data']); // Store referral object
265
 
266
 
267
- /* Store Conversion Data to LANDING PAGE/CTA DATA */
268
  if ($lead_data['post_type'] == 'landing-page' || $lead_data['post_type'] == 'wp-call-to-action')
269
  {
270
  $page_conversion_data = get_post_meta( $lead_data['page_id'], 'inbound_conversion_data', TRUE );
@@ -375,7 +361,7 @@ function inbound_store_lead( $args = array( ) ) {
375
  do_action('wpl_store_lead_post', $lead_data );
376
  do_action('lp_store_lead_post', $lead_data );
377
 
378
- if (!$args) {
379
 
380
  echo $lead_id;
381
  die();
@@ -421,7 +407,7 @@ function inbound_add_conversion_to_lead( $lead_id, $lead_data ) {
421
 
422
 
423
  /**
424
- * Loop trough lead_data array and update post meta
425
  */
426
  function inbound_update_common_meta($lead_data)
427
  {
@@ -444,7 +430,37 @@ function inbound_update_common_meta($lead_data)
444
  }
445
  }
446
 
 
 
 
 
 
447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
 
449
  function inbound_json_array_merge( $arr1, $arr2 ) {
450
  $keys = array_keys( $arr2 );
@@ -484,7 +500,7 @@ function inbound_search_args_for_mapped_data( $lead_data , $args ) {
484
  add_action( 'inboundnow_store_lead_pre_filter_data' , 'inbound_search_args_for_mapped_data' , 10 , 2);
485
 
486
  /**
487
- * Assembles first,last, & full name from partial data
488
  */
489
  function inbound_check_lead_name( $lead_data ) {
490
 
@@ -515,4 +531,62 @@ function inbound_check_lead_name( $lead_data ) {
515
 
516
  return $lead_data;
517
  }
518
- add_action( 'inboundnow_store_lead_pre_filter_data' , 'inbound_check_lead_name' , 10 , 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  $search_array = array();
37
  foreach ($search as $key => $value) {
38
  $search_array[$count] = array( 'date' => $search[$count]['date'],
39
+ 'value' => $search[$count]['value']);
40
  $count++;
41
  }
42
 
75
  add_action('wp_ajax_nopriv_inbound_store_lead', 'inbound_store_lead' ,10 , 1);
76
 
77
  /**
78
+ * This method needs to be rebuilt
79
  */
80
+ function inbound_store_lead( $args = array( ) , $return = false ) {
81
  global $user_ID, $wpdb;
82
 
83
  if (!is_array($args)) {
92
  $lead_data['user_ID'] = $user_ID;
93
  $lead_data['wordpress_date_time'] = date("Y-m-d G:i:s T", $time);
94
  $lead_data['wpleads_email_address'] = (isset($args['emailTo'])) ? $args['emailTo'] : false;
95
+ $lead_data['page_views'] = (isset($args['page_views'])) ? $args['page_views'] : false;
96
  $lead_data['form_input_values'] = (isset($args['form_input_values'])) ? $args['form_input_values'] : false; // raw post data
97
 
98
  /* Attempt to populate lead data through mappped fields */
105
  $lead_data['post_type'] = (array_key_exists('post_type', $mapped_data)) ? $mapped_data['post_type'] : false;
106
  $lead_data['wp_lead_uid'] = (array_key_exists('wp_lead_uid', $mapped_data)) ? $mapped_data['wp_lead_uid'] : false;
107
  $lead_data['lead_lists'] = (array_key_exists('leads_list', $mapped_data)) ? explode(",", $mapped_data['leads_list']) : false;
108
+ $lead_data['ip_address'] = inbound_get_ip_address();
109
 
110
 
111
  /* Check first level for data related to lead submit */
119
  $lead_data['search_data'] = $search_data;
120
 
121
  /* Legacy - needs to be phased out - search for alias key matches */
122
+ $lead_data['wpleads_full_name'] = (isset($args['full_name'])) ? $args['full_name'] : "";
123
+ $lead_data['wpleads_first_name'] = (isset($args['first_name'])) ? $args['first_name'] : "";
124
  $lead_data['wpleads_last_name'] = (isset($args['last_name'])) ? $args['last_name'] : "";
125
  $lead_data['wpleads_company_name'] = (isset($args['company_name'] )) ? $args['company_name'] : "";
126
  $lead_data['wpleads_mobile_phone'] = (isset($args['phone'])) ? $args['phone'] : "";
136
  do_action('inbound_store_lead_pre' , $lead_data , $args ); // Global lead storage action hook
137
 
138
  /* bail if spam */
139
+ if (apply_filters( 'inbound_check_if_spam' , false , $lead_data )) {
140
  exit;
141
  }
142
 
165
  /* Create New Lead */
166
  $post = array(
167
  'post_title' => $lead_data['wpleads_email_address'],
168
+ //'post_content' => $json,
169
  'post_status' => 'publish',
170
  'post_type' => 'wp-lead',
171
  'post_author' => 1
174
  //$post = add_filter('lp_leads_post_vars',$post);
175
  $lead_data['lead_id'] = wp_insert_post($post);
176
  $lead_id = $lead_data['lead_id'];
 
177
 
178
  /* updates common meta for new leads */
179
  inbound_update_common_meta($lead_data);
187
  }
188
 
189
  /***
190
+ * Run Processes for all Leads below
191
+ ***/
192
  do_action('wpleads_after_conversion_lead_insert',$lead_id); // action hook on all lead inserts
193
 
194
  update_post_meta( $lead_id, 'wpleads_inbound_form_mapped_data', $lead_data['Mapped_Data']);
228
 
229
  /* Store IP addresss & Store GEO Data */
230
  if ($lead_data['ip_address']) {
231
+ inbound_update_geolocation_data( $lead_data );
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  }
233
 
234
  /* Store Conversion Data to Lead */
250
  update_post_meta($lead_id, 'wpleads_referral_data', $lead_data['referral_data']); // Store referral object
251
 
252
 
253
+ /* Store Conversion Data to LANDING PAGE/CTA DATA */
254
  if ($lead_data['post_type'] == 'landing-page' || $lead_data['post_type'] == 'wp-call-to-action')
255
  {
256
  $page_conversion_data = get_post_meta( $lead_data['page_id'], 'inbound_conversion_data', TRUE );
361
  do_action('wpl_store_lead_post', $lead_data );
362
  do_action('lp_store_lead_post', $lead_data );
363
 
364
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX && !$return ) {
365
 
366
  echo $lead_id;
367
  die();
407
 
408
 
409
  /**
410
+ * Loop trough lead_data array and update post meta
411
  */
412
  function inbound_update_common_meta($lead_data)
413
  {
430
  }
431
  }
432
 
433
+ /**
434
+ * Connects to geoplugin.net and gets data on IP address and sets it into historical log
435
+ * @param ARRAY $lead_data
436
+ */
437
+ function inbound_update_geolocation_data( $lead_data ) {
438
 
439
+ $ip_addresses = get_post_meta( $post->ID , 'wpleads_ip_address', true );
440
+ $ip_addresses = json_decode( stripslashes($ip_addresses) , true);
441
+
442
+ if (!$ip_addresses) {
443
+ $ip_addresses = array();
444
+ }
445
+
446
+ $new_record[ $lead_data['ip_address'] ]['ip_address'] = $lead_data['ip_address'];
447
+
448
+
449
+ /* ignore for local environments */
450
+ if ($lead_data['ip_address']!= "127.0.0.1"){ // exclude localhost
451
+ $response = wp_remote_get('http://www.geoplugin.net/php.gp?ip='.$lead_data['ip_address']);
452
+ if ( isset( $response['body'] ) ) {
453
+ $geo_array = @unserialize( $response['body'] );
454
+ $new_record[ $lead_data['ip_address'] ]['geodata'] = $geo_array;
455
+ }
456
+
457
+ }
458
+
459
+ $ip_addresses = array_merge( $new_record , $ip_addresses );
460
+ $ip_addresses = json_encode( $ip_addresses );
461
+
462
+ update_post_meta( $lead_data['lead_id'], 'wpleads_ip_address', $ip_addresses );
463
+ }
464
 
465
  function inbound_json_array_merge( $arr1, $arr2 ) {
466
  $keys = array_keys( $arr2 );
500
  add_action( 'inboundnow_store_lead_pre_filter_data' , 'inbound_search_args_for_mapped_data' , 10 , 2);
501
 
502
  /**
503
+ * Assembles first,last, & full name from partial data
504
  */
505
  function inbound_check_lead_name( $lead_data ) {
506
 
531
 
532
  return $lead_data;
533
  }
534
+ add_action( 'inboundnow_store_lead_pre_filter_data' , 'inbound_check_lead_name' , 10 , 1);
535
+
536
+ /**
537
+ * Loads correct lead UID during a login
538
+ */
539
+ function inbound_load_tracking_cookie( $user_login, $user) {
540
+
541
+ if (!isset($user->data->user_email)) {
542
+ return;
543
+ }
544
+
545
+ global $wp_query;
546
+
547
+ /* search leads cpt for record containing email & get UID */
548
+ $results = new WP_Query( array( 'post_type' => 'wp-lead' , 's' => $user->data->user_email ) );
549
+
550
+ if (!$results) {
551
+ return;
552
+ }
553
+
554
+ if ( $results->have_posts() ) {
555
+ while ( $results->have_posts() ) {
556
+
557
+ $uid = get_post_meta( $results->post->ID , 'wp_leads_uid' , true );
558
+
559
+ if (!$uid) {
560
+ return;
561
+ }
562
+
563
+ setcookie( 'wp_lead_uid' , $uid , time() + (20 * 365 * 24 * 60 * 60),'/');
564
+ return;
565
+ }
566
+ }
567
+ }
568
+ add_action('wp_login', 'inbound_load_tracking_cookie', 10, 2);
569
+
570
+ /**
571
+ * Get IP Address, check for x-forwarded-for header first and falls back on the server remote address
572
+ * @returns STRING ip address
573
+ */
574
+ function inbound_get_ip_address() {
575
+ if(isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
576
+ if(isset($_SERVER["HTTP_CLIENT_IP"])) {
577
+ $proxy = $_SERVER["HTTP_CLIENT_IP"];
578
+ } else {
579
+ $proxy = $_SERVER["REMOTE_ADDR"];
580
+ }
581
+
582
+ $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
583
+ } else {
584
+ if(isset($_SERVER["HTTP_CLIENT_IP"])) {
585
+ $ip = $_SERVER["HTTP_CLIENT_IP"];
586
+ } else {
587
+ $ip = $_SERVER["REMOTE_ADDR"];
588
+ }
589
+ }
590
+
591
+ return $ip;
592
+ }
templates/countdown-lander/config.php CHANGED
@@ -48,7 +48,7 @@ array(
48
 
49
  <strong>In this guide you will learn:</strong>
50
 
51
- [list icon="ok-sign" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
52
  <ul>
53
  <li>This list was created with the list icon shortcode.</li>
54
  <li>Click on the power icon in your editor to customize your own</li>
48
 
49
  <strong>In this guide you will learn:</strong>
50
 
51
+ [list icon="check" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
52
  <ul>
53
  <li>This list was created with the list icon shortcode.</li>
54
  <li>Click on the power icon in your editor to customize your own</li>
templates/default/config.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  * Default theme single.php template
3
  *
4
  * To customize your default landing page, create a single-landing-page.php and customize
5
  * http://docs.inboundnow.com/landing-pages/dev/creating-templates/default-wp-themes
6
  *
7
  * DO NOT USE THE DEFAULT TEMPLATE FOR INNOVATING NEW THEMES! Instead use the demo template or any other the others
8
  */
9
  array(
10
  'label' => 'Default Instructions', // Name of field
11
  'description' => "<strong><u>Default Template Instructions</u></strong><br> This landing page template uses the single.php file of your current active theme. You might need to customize some components to get it looking the way you want. <a href=\"#\" onClick=\"window.open('http://www.youtube.com/embed/pQzmx4ooL1M?autoplay=1','landing-page','width=640,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')\">Watch Video Explanation</a>", // what field does
12
  'id' => 'description', // metakey. $key Prefix is appended from parent in array loop
13
  'type' => 'description-block', // metafield type
14
  'default' => '', // default content
15
  'context' => 'normal' // Context in screen (advanced layouts in future)
16
  ),
17
  array(
18
  'label' => "Default Content",
19
  'description' => "This is the default content from template.",
20
  'id' => "default-content",
21
  'type' => "default-content",
22
  'default' => '<p>This is the first paragraph of your landing page. You want to grab the visitors attention and describe a commonly felt problem that they might be experiencing. Try and relate to your target audience and draw them in.</p>
23
  <li>This list was created with the list icon shortcode.</li>
24
  <li>Click on the power icon in your editor to customize your own</li>
25
  <li>Explain why users will want to fill out the form</li>
26
  <li>Keep it short and sweet.</li>
27
  <li>This list should be easily scannable</li>
28
  ),
29
  array(
30
  'label' => 'Conversion/Form Placement', // Label of field
31
  'description' => "Where should the conversion area show on the page? When setting to 'Use Widget' make sure that the 'Conversion Area Widget' is added to the 'Landing Page Sidebar' for the conversion area to display properly.", // field description
32
  'id' => 'conversion-area-placement', // metakey.
33
  'type' => 'dropdown', // text metafield type
34
  'default' => 'widget', // default content
35
  'options' => array('widget'=>'Use Sidebar Widget (default)','right'=>'Float Form Area Right', 'left'=>'Float Form Area Left','bottom'=>'Insert Below Content','top'=>'Insert Above Content'), // options for radio
36
  'context' => 'normal' // Context in screen for organizing options
37
  ),
38
  array(
39
  'label' => "Navigation Settings",
40
  'description' => "Toggle the regular navigation on or off with this setting. It's highly recommended that you turn off your page navigation to increase conversion rates on your landing page",
41
  'id' => 'lp_hide_nav',
42
  'type' => 'dropdown',
43
  'default' => 'off',
44
  'options' => array('off'=>'Hide Navigation (recommended)','on'=>'Show Navigation'),
45
  'context' => 'normal'
46
  )
 
47
  * Default theme single.php template
48
  *
49
  * To customize your default landing page, create a single-landing-page.php and customize
50
  * http://docs.inboundnow.com/landing-pages/dev/creating-templates/default-wp-themes
51
  *
52
  * DO NOT USE THE DEFAULT TEMPLATE FOR INNOVATING NEW THEMES! Instead use the demo template or any other the others
53
  */
54
  array(
55
  'label' => 'Default Instructions', // Name of field
56
  'description' => "<strong><u>Default Template Instructions</u></strong><br> This landing page template uses the single.php file of your current active theme. You might need to customize some components to get it looking the way you want. <a href=\"#\" onClick=\"window.open('http://www.youtube.com/embed/pQzmx4ooL1M?autoplay=1','landing-page','width=640,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')\">Watch Video Explanation</a>", // what field does
57
  'id' => 'description', // metakey. $key Prefix is appended from parent in array loop
58
  'type' => 'description-block', // metafield type
59
  'default' => '', // default content
60
  'context' => 'normal' // Context in screen (advanced layouts in future)
61
  ),
62
  array(
63
  'label' => "Default Content",
64
  'description' => "This is the default content from template.",
65
  'id' => "default-content",
66
  'type' => "default-content",
67
  'default' => '<p>This is the first paragraph of your landing page. You want to grab the visitors attention and describe a commonly felt problem that they might be experiencing. Try and relate to your target audience and draw them in.</p>
68
  <li>This list was created with the list icon shortcode.</li>
69
  <li>Click on the power icon in your editor to customize your own</li>
70
  <li>Explain why users will want to fill out the form</li>
71
  <li>Keep it short and sweet.</li>
72
  <li>This list should be easily scannable</li>
73
  ),
74
  array(
75
  'label' => 'Conversion/Form Placement', // Label of field
76
  'description' => "Where should the conversion area show on the page? When setting to 'Use Widget' make sure that the 'Conversion Area Widget' is added to the 'Landing Page Sidebar' for the conversion area to display properly.", // field description
77
  'id' => 'conversion-area-placement', // metakey.
78
  'type' => 'dropdown', // text metafield type
79
  'default' => 'widget', // default content
80
  'options' => array('widget'=>'Use Sidebar Widget (default)','right'=>'Float Form Area Right', 'left'=>'Float Form Area Left','bottom'=>'Insert Below Content','top'=>'Insert Above Content'), // options for radio
81
  'context' => 'normal' // Context in screen for organizing options
82
  ),
83
  array(
84
  'label' => "Navigation Settings",
85
  'description' => "Toggle the regular navigation on or off with this setting. It's highly recommended that you turn off your page navigation to increase conversion rates on your landing page",
86
  'id' => 'lp_hide_nav',
87
  'type' => 'dropdown',
88
  'default' => 'off',
89
  'options' => array('off'=>'Hide Navigation (recommended)','on'=>'Show Navigation'),
90
  'context' => 'normal'
91
  )
 
1
  * Default theme single.php template
2
  *
3
  * To customize your default landing page, create a single-landing-page.php and customize
4
  * http://docs.inboundnow.com/landing-pages/dev/creating-templates/default-wp-themes
5
  *
6
  * DO NOT USE THE DEFAULT TEMPLATE FOR INNOVATING NEW THEMES! Instead use the demo template or any other the others
7
  */
8
  array(
9
  'label' => 'Default Instructions', // Name of field
10
  'description' => "<strong><u>Default Template Instructions</u></strong><br> This landing page template uses the single.php file of your current active theme. You might need to customize some components to get it looking the way you want. <a href=\"#\" onClick=\"window.open('http://www.youtube.com/embed/pQzmx4ooL1M?autoplay=1','landing-page','width=640,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')\">Watch Video Explanation</a>", // what field does
11
  'id' => 'description', // metakey. $key Prefix is appended from parent in array loop
12
  'type' => 'description-block', // metafield type
13
  'default' => '', // default content
14
  'context' => 'normal' // Context in screen (advanced layouts in future)
15
  ),
16
  array(
17
  'label' => "Default Content",
18
  'description' => "This is the default content from template.",
19
  'id' => "default-content",
20
  'type' => "default-content",
21
  'default' => '<p>This is the first paragraph of your landing page. You want to grab the visitors attention and describe a commonly felt problem that they might be experiencing. Try and relate to your target audience and draw them in.</p>
22
  <li>This list was created with the list icon shortcode.</li>
23
  <li>Click on the power icon in your editor to customize your own</li>
24
  <li>Explain why users will want to fill out the form</li>
25
  <li>Keep it short and sweet.</li>
26
  <li>This list should be easily scannable</li>
27
  ),
28
  array(
29
  'label' => 'Conversion/Form Placement', // Label of field
30
  'description' => "Where should the conversion area show on the page? When setting to 'Use Widget' make sure that the 'Conversion Area Widget' is added to the 'Landing Page Sidebar' for the conversion area to display properly.", // field description
31
  'id' => 'conversion-area-placement', // metakey.
32
  'type' => 'dropdown', // text metafield type
33
  'default' => 'widget', // default content
34
  'options' => array('widget'=>'Use Sidebar Widget (default)','right'=>'Float Form Area Right', 'left'=>'Float Form Area Left','bottom'=>'Insert Below Content','top'=>'Insert Above Content'), // options for radio
35
  'context' => 'normal' // Context in screen for organizing options
36
  ),
37
  array(
38
  'label' => "Navigation Settings",
39
  'description' => "Toggle the regular navigation on or off with this setting. It's highly recommended that you turn off your page navigation to increase conversion rates on your landing page",
40
  'id' => 'lp_hide_nav',
41
  'type' => 'dropdown',
42
  'default' => 'off',
43
  'options' => array('off'=>'Hide Navigation (recommended)','on'=>'Show Navigation'),
44
  'context' => 'normal'
45
  )
46
+ <?php
47
  * Default theme single.php template
48
  *
49
  * To customize your default landing page, create a single-landing-page.php and customize
50
  * http://docs.inboundnow.com/landing-pages/dev/creating-templates/default-wp-themes
51
  *
52
  * DO NOT USE THE DEFAULT TEMPLATE FOR INNOVATING NEW THEMES! Instead use the demo template or any other the others
53
  */
54
  array(
55
  'label' => 'Default Instructions', // Name of field
56
  'description' => "<strong><u>Default Template Instructions</u></strong><br> This landing page template uses the single.php file of your current active theme. You might need to customize some components to get it looking the way you want. <a href=\"#\" onClick=\"window.open('http://www.youtube.com/embed/pQzmx4ooL1M?autoplay=1','landing-page','width=640,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no')\">Watch Video Explanation</a>", // what field does
57
  'id' => 'description', // metakey. $key Prefix is appended from parent in array loop
58
  'type' => 'description-block', // metafield type
59
  'default' => '', // default content
60
  'context' => 'normal' // Context in screen (advanced layouts in future)
61
  ),
62
  array(
63
  'label' => "Default Content",
64
  'description' => "This is the default content from template.",
65
  'id' => "default-content",
66
  'type' => "default-content",
67
  'default' => '<p>This is the first paragraph of your landing page. You want to grab the visitors attention and describe a commonly felt problem that they might be experiencing. Try and relate to your target audience and draw them in.</p>
68
  <li>This list was created with the list icon shortcode.</li>
69
  <li>Click on the power icon in your editor to customize your own</li>
70
  <li>Explain why users will want to fill out the form</li>
71
  <li>Keep it short and sweet.</li>
72
  <li>This list should be easily scannable</li>
73
  ),
74
  array(
75
  'label' => 'Conversion/Form Placement', // Label of field
76
  'description' => "Where should the conversion area show on the page? When setting to 'Use Widget' make sure that the 'Conversion Area Widget' is added to the 'Landing Page Sidebar' for the conversion area to display properly.", // field description
77
  'id' => 'conversion-area-placement', // metakey.
78
  'type' => 'dropdown', // text metafield type
79
  'default' => 'widget', // default content
80
  'options' => array('widget'=>'Use Sidebar Widget (default)','right'=>'Float Form Area Right', 'left'=>'Float Form Area Left','bottom'=>'Insert Below Content','top'=>'Insert Above Content'), // options for radio
81
  'context' => 'normal' // Context in screen for organizing options
82
  ),
83
  array(
84
  'label' => "Navigation Settings",
85
  'description' => "Toggle the regular navigation on or off with this setting. It's highly recommended that you turn off your page navigation to increase conversion rates on your landing page",
86
  'id' => 'lp_hide_nav',
87
  'type' => 'dropdown',
88
  'default' => 'off',
89
  'options' => array('off'=>'Hide Navigation (recommended)','on'=>'Show Navigation'),
90
  'context' => 'normal'
91
  )
templates/dropcap/assets/css/style.css CHANGED
@@ -130,5 +130,9 @@ margin-bottom: 5px;
130
  display: block;
131
  font-size: 18px;
132
  }
 
 
 
 
133
  .lp-input-label:nth-of-type(1)
134
  { margin-top: 5px;}
130
  display: block;
131
  font-size: 18px;
132
  }
133
+ #content {
134
+ margin-bottom: 80px;
135
+ padding-bottom: 40px;
136
+ }
137
  .lp-input-label:nth-of-type(1)
138
  { margin-top: 5px;}
templates/dropcap/index.php CHANGED
@@ -117,4 +117,10 @@ do_action('lp_footer'); // Load Landing Page Footer Hook
117
  wp_footer();
118
  ?>
119
  <link href="<?php echo $path; ?>assets/css/form.css" rel="stylesheet">
 
 
 
 
 
 
120
  </body></html>
117
  wp_footer();
118
  ?>
119
  <link href="<?php echo $path; ?>assets/css/form.css" rel="stylesheet">
120
+ <script type="text/javascript">
121
+ jQuery(document).ready(function($) {
122
+ $("p:empty").remove();
123
+ });
124
+
125
+ </script>
126
  </body></html>
templates/simple-solid-lite/config.php CHANGED
@@ -38,7 +38,7 @@ $lp_data[$key]['settings'] = array(
38
 
39
  <strong>In this guide you will learn:</strong>
40
 
41
- [list icon="ok-sign" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
42
  <ul>
43
  <li>This list was created with the list icon shortcode.</li>
44
  <li>Click on the power icon in your editor to customize your own</li>
@@ -71,7 +71,7 @@ $lp_data[$key]['settings'] = array(
71
  'description' => "",
72
  'id' => "social-media-options",
73
  'type' => "textarea",
74
- 'default' => '[social_share style="bar" align="horizontal" heading_align="inline" heading="Share This" facebook="1" twitter="1" google_plus="1" linkedin="1" pinterest="0" /]',
75
  'selector' => ".inner .network",
76
  ),
77
  array(
38
 
39
  <strong>In this guide you will learn:</strong>
40
 
41
+ [list icon="check" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
42
  <ul>
43
  <li>This list was created with the list icon shortcode.</li>
44
  <li>Click on the power icon in your editor to customize your own</li>
71
  'description' => "",
72
  'id' => "social-media-options",
73
  'type' => "textarea",
74
+ 'default' => '[social_share style="bar" align="horizontal" heading_align="inline" heading="" facebook="1" twitter="1" google_plus="1" linkedin="1" pinterest="0" /]',
75
  'selector' => ".inner .network",
76
  ),
77
  array(
templates/simple-solid-lite/css/main.css CHANGED
@@ -13,7 +13,23 @@ video,
13
  canvas {
14
  max-width: 100%;
15
  }
16
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  html {
18
  min-height: 100%;
19
  margin-bottom: 1px;
@@ -119,7 +135,7 @@ header {
119
  float: right;
120
  color: #2ecc71;
121
  font-size: 15px;
122
- margin: 20px 0 0;
123
  width: 600px;
124
  text-align: right;
125
  }
13
  canvas {
14
  max-width: 100%;
15
  }
16
+ .gform_body ul {
17
+ margin:0px;padding: 0px;
18
+ }
19
+ .gform_body li {
20
+ list-style: none;
21
+ }
22
+ textarea {
23
+ padding-left: 20px;
24
+ padding-top: 20px;
25
+ font: 18px/1.5 'montserratregular','Montserrat',Helvetica,Arial,sans-serif;
26
+ }
27
+ .inbound_the_conversion_area {
28
+ padding-bottom: 40px;
29
+ }
30
+ .gform_body textarea {
31
+ width: 100%;
32
+ }
33
  html {
34
  min-height: 100%;
35
  margin-bottom: 1px;
135
  float: right;
136
  color: #2ecc71;
137
  font-size: 15px;
138
+ margin: 15px 0 0;
139
  width: 600px;
140
  text-align: right;
141
  }
templates/svtle/assets/css/style.css CHANGED
@@ -7,6 +7,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, nav, sectio
7
  display: inline;
8
  color:red;
9
  }
 
10
  input[type="text"], input[type="email"], button[type='submit'] {
11
  width: 97%;
12
  padding: 8px 4px 8px 10px;
@@ -15,7 +16,7 @@ border: 1px solid #4E3043;
15
  border: 1px solid rgba(78, 48, 67, 0.8);
16
  background: rgba(0, 0, 0, 0.15);
17
  border-radius: 2px;
18
- box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 1px 1px rgba(0, 0, 0, 0.1);
19
  -webkit-transition: all 0.3s ease-out;
20
  -moz-transition: all 0.3s ease-out;
21
  -ms-transition: all 0.3s ease-out;
@@ -23,24 +24,12 @@ box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 1px 1px rgba(0, 0, 0, 0.1)
23
  transition: all 0.3s ease-out;
24
  font-family: 'Raleway', 'Lato', Arial, sans-serif;
25
  color: white;
26
- font-size: 13px; /*
27
-
28
- display: block;
29
- padding: 5px;
30
- border: 4px solid #F1B720;
31
- border-radius: 5px;
32
- color: #333;
33
- transition: all 0.3s ease-out; */
34
  }
35
- /*
36
- input[type="text"]:hover { border-radius: 8px; }
37
- input[type="text"]:focus {
38
- outline: none;
39
- border-radius: 8px;
40
- border-color: #EBD292;
41
  }
42
- */
43
-
44
 
45
  input[type="submit"], button[type='submit'] {
46
  width: 95%;
@@ -54,7 +43,6 @@ background: -webkit-linear-gradient(rgba(99, 64, 86, 0.5), rgba(76, 49, 65, 0.7)
54
  background: linear-gradient(rgba(99, 64, 86, 0.5), rgba(76, 49, 65, 0.7));
55
  border-radius: 5px;
56
  border: 1px solid #4E3043;
57
- box-shadow: inset 0 1px rgba(255, 255, 255, 0.4), 0 2px 1px rgba(0, 0, 0, 0.1);
58
  cursor: pointer;
59
  -webkit-transition: all 0.3s ease-out;
60
  -moz-transition: all 0.3s ease-out;
@@ -655,7 +643,6 @@ li {
655
  font-size:15px;
656
  line-height:25px;
657
  margin:0;
658
- color:#4d4d4d;
659
  display:list-item;
660
  margin-bottom:5px;
661
  margin-top:5px;
@@ -788,7 +775,8 @@ code {
788
  header#sidebar {
789
  width:27%;
790
  padding-left:1.5%;
791
- position:fixed;
 
792
  z-index:1;
793
  min-height:100%;
794
  min-width:240px;
@@ -1028,7 +1016,7 @@ article.post {
1028
  padding-left:50px;
1029
  padding-top:40px;
1030
  padding-bottom:40px;
1031
- border-top:1px solid #e2e2e2;
1032
  min-height:130px;
1033
  overflow-x:hidden;
1034
  }
7
  display: inline;
8
  color:red;
9
  }
10
+ #sidebar { overflow: auto;}
11
  input[type="text"], input[type="email"], button[type='submit'] {
12
  width: 97%;
13
  padding: 8px 4px 8px 10px;
16
  border: 1px solid rgba(78, 48, 67, 0.8);
17
  background: rgba(0, 0, 0, 0.15);
18
  border-radius: 2px;
19
+
20
  -webkit-transition: all 0.3s ease-out;
21
  -moz-transition: all 0.3s ease-out;
22
  -ms-transition: all 0.3s ease-out;
24
  transition: all 0.3s ease-out;
25
  font-family: 'Raleway', 'Lato', Arial, sans-serif;
26
  color: white;
27
+ font-size: 13px;
 
 
 
 
 
 
 
28
  }
29
+ textarea {
30
+ padding-top: 7px;
31
+ padding-left: 7px;
 
 
 
32
  }
 
 
33
 
34
  input[type="submit"], button[type='submit'] {
35
  width: 95%;
43
  background: linear-gradient(rgba(99, 64, 86, 0.5), rgba(76, 49, 65, 0.7));
44
  border-radius: 5px;
45
  border: 1px solid #4E3043;
 
46
  cursor: pointer;
47
  -webkit-transition: all 0.3s ease-out;
48
  -moz-transition: all 0.3s ease-out;
643
  font-size:15px;
644
  line-height:25px;
645
  margin:0;
 
646
  display:list-item;
647
  margin-bottom:5px;
648
  margin-top:5px;
775
  header#sidebar {
776
  width:27%;
777
  padding-left:1.5%;
778
+ position:absolute;
779
+ overflow: auto;
780
  z-index:1;
781
  min-height:100%;
782
  min-width:240px;
1016
  padding-left:50px;
1017
  padding-top:40px;
1018
  padding-bottom:40px;
1019
+ border-top:1px solid transparent;
1020
  min-height:130px;
1021
  overflow-x:hidden;
1022
  }
templates/svtle/config.php CHANGED
@@ -39,7 +39,7 @@ array(
39
 
40
  <strong>In this guide you will learn:</strong>
41
 
42
- [list icon="ok-sign" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
43
  <ul>
44
  <li>This list was created with the list icon shortcode.</li>
45
  <li>Click on the power icon in your editor to customize your own</li>
39
 
40
  <strong>In this guide you will learn:</strong>
41
 
42
+ [list icon="check" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
43
  <ul>
44
  <li>This list was created with the list icon shortcode.</li>
45
  <li>Click on the power icon in your editor to customize your own</li>
templates/svtle/index.php CHANGED
@@ -123,13 +123,14 @@ $blue = (isset($RBG_array['b'])) ? $RBG_array['b'] : '0';
123
  color:#000;
124
  }
125
  }
 
126
  </style>
127
  <script type="text/javascript">
128
  jQuery(document).ready(function($) {
129
  $(function () {
130
  $('figure, picture').picture();
131
  });
132
- var window_size = jQuery(window).height();
133
  jQuery("#river").height(window_size);
134
  });
135
  </script>
123
  color:#000;
124
  }
125
  }
126
+
127
  </style>
128
  <script type="text/javascript">
129
  jQuery(document).ready(function($) {
130
  $(function () {
131
  $('figure, picture').picture();
132
  });
133
+ var window_size = jQuery(document).height();
134
  jQuery("#river").height(window_size);
135
  });
136
  </script>
templates/three-column-lander/config.php CHANGED
@@ -40,7 +40,7 @@ array(
40
 
41
  <strong>In this guide you will learn:</strong>
42
 
43
- [list icon="ok-sign" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
44
  <ul>
45
  <li>This list was created with the list icon shortcode.</li>
46
  <li>Click on the power icon in your editor to customize your own</li>
40
 
41
  <strong>In this guide you will learn:</strong>
42
 
43
+ [list icon="check" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
44
  <ul>
45
  <li>This list was created with the list icon shortcode.</li>
46
  <li>Click on the power icon in your editor to customize your own</li>
templates/tubelar/config.php CHANGED
@@ -58,7 +58,7 @@ array(
58
 
59
  <strong>In this guide you will learn:</strong>
60
 
61
- [list icon="ok-sign" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
62
  <ul>
63
  <li>This list was created with the list icon shortcode.</li>
64
  <li>Click on the power icon in your editor to customize your own</li>
58
 
59
  <strong>In this guide you will learn:</strong>
60
 
61
+ [list icon="check" font_size="16" icon_color="#00a319" text_color="" bottom_margin="10"]
62
  <ul>
63
  <li>This list was created with the list icon shortcode.</li>
64
  <li>Click on the power icon in your editor to customize your own</li>
tests/travis-ci/bootstrap.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bootstrap the plugin unit testing environment.
4
+ *
5
+ * Edit 'active_plugins' setting below to point to your main plugin file.
6
+ *
7
+ * @package wordpress-plugin-tests
8
+ */
9
+
10
+ // Activates this plugin in WordPress so it can be tested.
11
+ $GLOBALS['wp_tests_options'] = array(
12
+ 'active_plugins' => array(
13
+ 'landing-pages/landing-pages.php',
14
+ 'cta/wordpress-cta.php',
15
+ 'leads/wordpress-leads.php',
16
+ ),
17
+ );
18
+
19
+ // If the develop repo location is defined (as WP_DEVELOP_DIR), use that
20
+ // location. Otherwise, we'll just assume that this plugin is installed in a
21
+ // WordPress develop SVN checkout.
22
+
23
+ if( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
24
+ require getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/bootstrap.php';
25
+ } else {
26
+ require '../../../../tests/phpunit/includes/bootstrap.php';
27
+ }
28
+
29
+ ?>
tests/travis-ci/test.activations.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Tests to test that that testing framework is testing tests. Meta, huh?
5
+ *
6
+ * @package wordpress-plugins-tests
7
+ */
8
+ class Tests_Activation extends WP_UnitTestCase {
9
+
10
+ /**
11
+ * Run a simple test to ensure that the tests are running
12
+ */
13
+ function test_tests() {
14
+ $this->assertTrue( true );
15
+ }
16
+
17
+ /**
18
+ * Ensure landing pages is active
19
+ */
20
+ function test_lading_pages_activated() {
21
+ $this->assertTrue( is_plugin_active( 'landing-pages/landing-pages.php' ) );
22
+ }
23
+
24
+ /**
25
+ * Ensure that the Leads has been installed and activated.
26
+ */
27
+ function test_leads_activated() {
28
+ $this->assertTrue( is_plugin_active( 'leads/wordpress-leads.php' ) );
29
+ }
30
+
31
+ /**
32
+ * Ensure that the Calls to Action has been installed and activated.
33
+ */
34
+ function test_cta_activated() {
35
+ $this->assertTrue( is_plugin_active( 'cta/wordpress-cta.php' ) );
36
+ }
37
+
38
+ /**
39
+ * Run upgrade routines and check option to see if complete
40
+ */
41
+ function test_run_upgrade_routines() {
42
+ include_once LANDINGPAGES_PATH . 'classes/class.activation.php';
43
+ include_once LANDINGPAGES_PATH . 'classes/class.activation.upgrade-routines.php';
44
+ Landing_Pages_Activation::run_updates();
45
+ $this->assertTrue( true );
46
+ }
47
+
48
+ }
49
+
50
+ ?>