How to use Segment with Prefinery

Segment is a customer data management and analytics solution that helps you make sense of customer data coming from multiple various sources. 

Like other supported integration tools - Zapier, Pabbly Connect, Integrately, Make, Sync Spider, and webhooks - integrating Prefinery with other apps/services using Segment allows you to send information about your campaign, most especially your users, to another platform. 

Here's how you can setup Segment with Prefinery: 

Installing the Segment Analytics.js Snippet

Much like how you would install the Prefinery JavaScript Snippet on your website, Segment also has their own JS snippet which you need to install on your website, or, in this case, on your Prefinery form. 

Here's how: 

1

In your Segment workspace dashboard, navigate to Connections > Catalog

2

In the Catalog, find and select Javascript then click Add Source on it. 

3

Give your Javascript Source a Name as well as other optional details, then click Add Source

4

In your newly created source's Overview tab, click on Copy Snippet

5

In your Prefinery project dashboard, navigate to Integrations > Code Injection, then paste in your copied snippet in the Head Code section and hit Save. 

6

To test that the Segment snippet is working properly on your form, navigate to Signup Form. When the form preview displays on this page, it will trigger a page view event for the Segment script. 

7

To confirm the above, in Segment and still in the source page, click on the Debugger tab and you should find a page view event like what's shown below. 

If you go back to the Overview tab and refresh the page (F5 on your keyboard), you will find that the source is now labeled as Enabled

Using a tracking method - "identify"

Segment offers different tracking methods, but for this guide we'll just cover the identify method

If you're looking to use a different tracking method, check out Segment's documentation and/or reach out to their support for assistance with implementing such method. 

Here's how: 

1

Following Segment's guide on using the identify method, from your project dashboard navigate to Signup Form > JS, and in the Conversion Tracking Code section enter your identify method script. 

As shown in the example, Prefinery allows you to map certain variables associated with user-submitted data to Segment traits like the user's name and email address. 

<script>
  analytics.identify({
    firstName: prefinery_data.user.profile.first_name,
    lastName: prefinery_data.user.profile.last_name,
    email: prefinery_data.user.email,
    createdAt: prefinery_data.user.created_at
  });
</script>
2

To test the above, do a test submission on your form. 

3

To confirm that the test submission went through, back in your Segment source page, go to its Debugger tab and you should find an identify event containing the mapped traits. 

4

That's it! You can now proceed with adding your destination following Segment's guide here: Sending Segment data to destinations

Still need help? How can we help? How can we help?