Instructions

Authenticate with the servers by entering your secret key below.

If you need a key, please visit our website to sign up.

Insert the shortcode [analyticsconnect-io] on your sales thank-you page.

Make sure that the "orderid" variable is being passed to the thank-you page containing the shortcode.

See our Installation and Troubleshooting Guide for additional information.

For advanced configuration options, see our API Documentation.

 

Status

Connection to :

Connection to Infusionsoft:

Google Analytics Tracking ID:

Plugin Shortcode:

 

Enter your ' . ANALYTICS_CONNECT_IO_APP_DISPLAY_NAME . ' secret key below to authenticate with the ' . ANALYTICS_CONNECT_IO_APP_DISPLAY_NAME . ' servers.

'; } // Display of the Authentication form element function analyticsconnectio_key_setting_string() { $options = get_option('analyticsconnectio_options'); echo ""; } // The instructions appearing above the Google Analytics Section function analyticsconnectio_section_gacode_settings_text() { echo '

If you already have a plugin that is injecting the Google Analytics tracking code into your WordPress install, leave this option turned off. If you need the Google Analytics tracking code installed, the below option will do it. It uses the information from your ' . ANALYTICS_CONNECT_IO_APP_DISPLAY_NAME . ' account to automatically create the Google Analytics code with cross-domain tracking and display features enabled.

'; } // Display of the Google Analytics form element function analyticsconnectio_gacode_setting_string() { $options = get_option('analyticsconnectio_options'); if ($options['gacode'] == 'true') { $isChecked = 'checked'; } else { $isChecked = ''; } echo ""; } // The instructions appearing above the Cookie System Section function analyticsconnectio_section_cookiesenable_settings_text() { echo '

If you have the Cookie Vault enabled from inside your ' . ANALYTICS_CONNECT_IO_APP_DISPLAY_NAME . ' account settings, you\'ll need to turn this on. For the Cookie Root Domain, unless you have reason to do otherwise, use "example.com" rather than "www.example.com", or "subdomain.example.com" so that the cookie is accessible to your entire domain.

'; } // Display of the Cookie System form element function analyticsconnectio_cookiesenable_setting_string() { $options = get_option('analyticsconnectio_options'); if ($options['cookiesenable'] == 'true') { $isChecked = 'checked'; } else { $isChecked = ''; } echo ""; } // Display of the Cookie Root Domain form element function analyticsconnectio_cookierootdomain_setting_string() { $options = get_option('analyticsconnectio_options'); echo ""; } // Sanitize input function analyticsconnectio_options_validate($input) { $options = get_option('analyticsconnectio_options'); // Secret Key $newinput['secret_key'] = trim($input['secret_key']); if (!preg_match('/^[a-z0-9]{24}$/i', $newinput['secret_key'])) { // Letters and numbers only, 24 characters long $newinput['secret_key'] = 'INVALID KEY FORMAT'; } // GA Code if ($input['gacode'] == 'true'){ $newinput['gacode'] = $input['gacode']; } else { $newinput['gacode'] = 'N'; } // Infusionsoft Application Name if (ctype_alnum($input['infappname'])) { $newinput['infappname'] = $input['infappname']; } else { $newinput['infappname'] = $options['infappname']; } // Google Analytics Code if (preg_match('/^([a-z0-9]+-)*[a-z0-9]+$/i', $input['gaua'])) { // Letters, numbers, and hyphens only (hyphen not repeated twice-in-a-row and not the begining/ending of the string) $newinput['gaua'] = $input['gaua']; } else { $newinput['gaua'] = $options['gaua']; } // Enable Cookie System if ($input['cookiesenable'] == 'true'){ $newinput['cookiesenable'] = $input['cookiesenable']; } else { $newinput['cookiesenable'] = 'N'; } // Cookie Root Domain if (preg_match('/^[a-z0-9.\-]+$/i', $input['cookierootdomain'])) { // Letters, numbers, ".", and "-" $newinput['cookierootdomain'] = strtolower($input['cookierootdomain']); } else { $newinput['cookierootdomain'] = $options['cookierootdomain']; } return $newinput; } // Add links on plugins page add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'analyticsconnect-io.php'), 'analyticsconnectio_action_links' ); function analyticsconnectio_action_links( $links ) { return array_merge( array( 'support' => 'Premium Support', 'settings' => 'Settings' ), $links ); } // Pull user data from server function analyticsconnectio_get_user_data(){ $options = get_option('analyticsconnectio_options'); // Pull info from WP database if (preg_match('/^[a-z0-9]{24}$/i', $options['secret_key'])) { // Only run if Secret Key has a valid format $curlPostData = array( 'secretkey' => $options['secret_key'] ); $curlPostBody = http_build_query($curlPostData); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => ANALYTICS_CONNECT_IO_CALLBACK_URL, CURLOPT_USERAGENT => ANALYTICS_CONNECT_IO_APP_DISPLAY_NAME . ' WordPress Plugin v' . ANALYTICS_CONNECT_IO_SOFTWARE_VERSION, CURLOPT_POST => 1, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_POSTFIELDS => $curlPostBody )); $result = curl_exec($curl); curl_close($curl); $data = json_decode($result, true); return $data; } else { // No key or invalid key format return FALSE; } } // Detect if user has inserted any of our shortcodes on any posts or pages function analyticsconnectio_shortcodes_detected() { $found = FALSE; $query_args = array('s' => '[analyticsconnect-io', 'post_type' => 'page'); $query = new WP_Query($query_args); if ($query->have_posts()) { $found = TRUE; } $query_args = array('s' => '[analyticsconnect-io', 'post_type' => 'post'); $query = new WP_Query($query_args); if ($query->have_posts()) { $found = TRUE; } return $found; } // Tweak user data into what we display inside the WordPress Admin and update the WordPress database function analyticsconnectio_get_displayable_user_data() { $options = get_option('analyticsconnectio_options'); // Pull info from WP database $rawData = analyticsconnectio_get_user_data(); if ($rawData == FALSE) { // We don't have any data because WordPress either doesn't have a key or the key has an invalid format $showData['status'] = '(Connection Error) Status Unknown'; if (strlen($options['infappname']) > 2) { $showData['infappname'] = '(Connection Error) Application ' . $options['infappname'] . ''; } else { $showData['infappname'] = '(Connection Error) Application Unknown'; } if (strlen($options['gaua']) > 2) { $showData['gaua'] = '(Connection Error) Currently set to ' . $options['gaua'] . ''; } else { $showData['gaua'] = '(Connection Error) No Tracking ID currently set'; } } else { // We got data back if ($rawData['status'] == 'error') { // Key lookup failed on the server $showData['status'] = 'Secret Key Error'; if (strlen($options['infappname']) > 2) { $showData['infappname'] = '(Connection Error) Application ' . $options['infappname'] . ''; } else { $showData['infappname'] = '(Connection Error) Application Unknown'; } if (strlen($options['gaua']) > 2) { $showData['gaua'] = '(Connection Error) Currently set to ' . $options['gaua'] . ''; } else { $showData['gaua'] = '(Connection Error) No Tracking ID currently set'; } } else { // We got good data back if ($rawData['status'] == 'active') { $showData['status'] = 'Active'; } else if ($rawData['status'] == 'trialing') { $showData['status'] = 'Active (Free Trial)'; } else if ($rawData['status'] == 'past_due') { $showData['status'] = 'Active (Your payment is past due!)'; } else if ($rawData['status'] == 'canceled') { $showData['status'] = 'Account Canceled'; } if ($rawData['infappname'] == NULL) { if (strlen($options['infappname']) > 2) { $showData['infappname'] = '(Connection Error) Application ' . $options['infappname'] . ''; } else { $showData['infappname'] = '(Connection Error) Application Unknown'; } } else { $showData['infappname'] = 'Application ' . $rawData['infappname'] . ''; // SAVE $rawData['infappname'] to WP DB $options = get_option('analyticsconnectio_options'); // Pull info from WP database $options['infappname'] = $rawData['infappname']; update_option('analyticsconnectio_options', $options); } if ($rawData['gaua'] == NULL) { if (strlen($options['gaua']) > 2) { $showData['gaua'] = '(Connection Error) Currently set to ' . $options['gaua'] . ''; } else { $showData['gaua'] = '(Connection Error) No Tracking ID currently set'; } } else { $showData['gaua'] = '' . $rawData['gaua'] . ''; // SAVE $rawData['gaua'] to WP DB $options = get_option('analyticsconnectio_options'); // Pull info from WP database $options['gaua'] = $rawData['gaua']; update_option('analyticsconnectio_options', $options); } } } if (analyticsconnectio_shortcodes_detected()) { $showData['shortcodestatus'] = 'Detected'; } else { $showData['shortcodestatus'] = '(WordPress Warning) No shortcodes detected'; } return $showData; } ?>