Segment is an analytics collection platform that passes user and event data to other platforms for analytics, tracking, and business intelligence purposes. By taking a few steps to coordinate your TUNE and Segment accounts, you can route that data to TUNE.
1. Check Settings in TUNE
In TUNE, make sure your offer uses the Server Postback w/Transaction ID tracking protocol. You can change an offer’s tracking protocol from the offer’s page. At the top of the Details panel, click Edit. On the page that appears, set Conversion Tracking to “Server Postback w/Transaction ID.”
Next, you must update your tracking settings for custom tracking domains. Go to Company > Customize Application > Settings > Tracking to do this. Then, set Maintain Custom Tracking Domains to “Disabled.”
2. Enable Integration in Segment
Once your offer is ready in TUNE, you’ll need to enable the integration in Segment.
To turn on the TUNE integration, go to your project page and select the Integrations tab. From there, find and enable the TUNE integration:
On the page that appears, select the Settings tab. Enter your TUNE Company ID, and click Save Changes when finished. Your Company ID is the first part of your TUNE URL: networkid.hasoffers.com.
3. Update Your Project
Before continuing with the integration, you need to have Segment set up for your project. That means analytics.js is imported wherever necessary and that identify and track are working properly for events you care about.
To connect to TUNE, modify the identify and track calls in your project using the steps below.
analytics.identify()
When connecting to TUNE, the transaction_id needs to be captured and passed to Segment from the landing page URL. In places where you call identify, include a way to get URL parameters and values from the query string—specifically to capture the TUNE transaction_id value:
var vars = getUrlVars(); var tid = if 'tid' in vars ? vars['tid'] : vars['transaction_id'];
To pass this information to Segment, include transaction_id (with its value from above) in the traits field of identify. You can use other traits as well. Just make sure to replace values in the call as you normally would for Segment.
analytics.identify(REPLACE_WITH_USER_ID, { transaction_id: tid, name: REPLACE_WITH_VALUE, email: REPLACE_WITH_VALUE });
analytics.track()
Next, you need to include the TUNE transaction_id value into Segment tracking. In places where you call track, load the transaction_id value from the traits array:
analytics.ready(function(){ var traits = analytics.user().traits(); analytics.track("REPLACE_WITH_EVENT_NAME", { adv_sub: REPLACE_WITH_VALUE, adv_sub2: REPLACE_WITH_VALUE, adv_sub3: REPLACE_WITH_VALUE, adv_sub4: REPLACE_WITH_VALUE, adv_sub5: REPLACE_WITH_VALUE, goal_id: REPLACE_WITH_VALUE, sale_amount: REPLACE_WITH_VALUE, payout: REPLACE_WITH_VALUE, revenue: REPLACE_WITH_VALUE }, { hasoffers: { transaction_id: traits['transaction_id'] } }); });
To include more information, you can optionally put additional TUNE parameters in the properties field of track. Like with identify, replace values in the call as you normally would for Segment.
Tip: All currently available optional parameters for this integration are included in the above snippet.
Having Trouble?
The above code snippets are ready to use in your project. However, you may need to modify them slightly to match how the project itself is implemented in your system.
For more help setting up this integration, contact the Segment support team. You can also find more detailed information on analytics.js, analytics.identify(), and analytics.track() in their technical documentation.