Title: Tracking code code for tracking started checkout not inserted
Last modified: December 3, 2020

---

# Tracking code code for tracking started checkout not inserted

 *  [Pepijn van Vlaanderen](https://wordpress.org/support/users/peppol/)
 * (@peppol)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/tracking-code-code-for-tracking-started-checkout-not-inserted/)
 * Hi,
 * The plug-in inserts a localize script for tracking a started checkout. However
   the implementation does not work.
 * In the file includes/wck-cart-functions.php on line 265 `wck_insert_checkout_tracking`
   function is creating a localize script through the `woocommerce_after_checkout_form`
   action, this results into nothing, because the script it localizes (wck_started_checkout)
   is not registered here.
 * I would suggest the following changes, which made it work for me:
 *     ```
       // Remove this hook add_action( 'woocommerce_after_checkout_form', 'wck_insert_checkout_tracking' );
   
       function load_started_checkout() {
           $token = get_option('klaviyo_settings')['public_api_key'];
   
           if ( is_checkout() ) {
               wp_enqueue_script( 'wck_started_checkout', plugins_url( '/js/wck-started-checkout.js', __FILE__ ), null, null, true );
               wp_localize_script( 'wck_started_checkout', 'public_key', array( 'token' => $token ));
               // Like the above line it should localize it here
               wck_insert_checkout_tracking();
           }
       }
   
       // $checkout variable is not used, so it can be removed as parameter
       function wck_insert_checkout_tracking($checkout) {
   
         global $current_user;
         wp_reset_query(); // Side question: Why is this here? And if it is needed why  is the main query not restored at the end of this function?
   
         ...function logic...
   
         // Pass Started Checkout event data to javascript attaching to 'wck_started_checkout' handle
         wp_localize_script( 'wck_started_checkout', 'kl_checkout', $started_checkout_data );
       }
       ```
   
    -  This topic was modified 5 years, 5 months ago by [Pepijn van Vlaanderen](https://wordpress.org/support/users/peppol/).

The topic ‘Tracking code code for tracking started checkout not inserted’ is closed
to new replies.

 * ![](https://ps.w.org/klaviyo/assets/icon-256x256.png?rev=2877261)
 * [Klaviyo](https://wordpress.org/plugins/klaviyo/)
 * [Support Threads](https://wordpress.org/support/plugin/klaviyo/)
 * [Active Topics](https://wordpress.org/support/plugin/klaviyo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/klaviyo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/klaviyo/reviews/)

 * 0 replies
 * 0 participants
 * Last reply from: [Pepijn van Vlaanderen](https://wordpress.org/support/users/peppol/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/tracking-code-code-for-tracking-started-checkout-not-inserted/)
 * Status: not resolved