Title: Analytics.js / Segment.com integration to capture user
Last modified: August 31, 2016

---

# Analytics.js / Segment.com integration to capture user

 *  Resolved [Elliot Taylor](https://wordpress.org/support/users/raisonon/)
 * (@raisonon)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/analyticsjs-segmentcom-integration-to-capture-user/)
 * I’m creating a sales funnel which looks like:
 * 1. View Site > 2. Email Signup > 3.Customer Purchase
 * Using Segment.com we can capture 1. and 3. If we can capture the email signup
   we can assign the the users who visited the site in stage 1.
 * Segment.com provide a single place to capture your site analytics and then push
   it out to multiple services. They use the open source analytics.js to capture
   this data and it’s very clean/simple method to capture.
 * I’m currently using this MailChimp plugin and want to capture/send the email 
   and and user ID on form submit.
 * This is possible with trackForm documented here: [https://segment.com/docs/libraries/analytics.js/](https://segment.com/docs/libraries/analytics.js/)
 * I wanted to see if you were aware of this and had any feedback before I had a
   go at integrating.
 * Having a segment.com integration would be ace.
 * Thanks
 * Elliot
 * [https://wordpress.org/plugins/mailchimp-for-wp/](https://wordpress.org/plugins/mailchimp-for-wp/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/analyticsjs-segmentcom-integration-to-capture-user/#post-6942524)
 * Hi Elliot,
 * I’d use the `success` event hook for this, it’s actually pretty easy. You can
   simply include the following code at the bottom of your form mark-up and things
   should work.
 *     ```
       mc4wp.forms.on('success', function( form, data ) {
       	analytics.track('Subscribed', {
       	  email: data.EMAIL
       	});
       });
       ```
   
 * You could expand this to your liking, maybe you haven’t identified the visitor
   yet? In my example I assumed you’d done that at step 1, but otherwise you could
   do something like this.
 *     ```
       mc4wp.forms.on('success', function( form, data ) {
       	analytics.identify({
                    email: data.EMAIL,
                    name: data.NAME,
                    newsletter: true
                });
       });
       ```
   
 * In the function callback, you have access to all the given form fields using 
   the `data` array. Log it to the console to see what’s in there.
 *     ```
       console.log( data );
       ```
   
 * The `form` object contains information about the filled form, like the form ID
   and the form name.
 *     ```
       console.log( form );
       ```
   
 * Hope that sets you off in the right direction! Good luck!
 * PS. If adding the above code to your form code, don’t forget to wrap it in `<
   script>` and `</script>`.

Viewing 1 replies (of 1 total)

The topic ‘Analytics.js / Segment.com integration to capture user’ is closed to 
new replies.

 * ![](https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png?rev=1224577)
 * [MC4WP: Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-wp/reviews/)

## Tags

 * [segment](https://wordpress.org/support/topic-tag/segment/)

 * 1 reply
 * 2 participants
 * Last reply from: [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/analyticsjs-segmentcom-integration-to-capture-user/#post-6942524)
 * Status: resolved