analytics.identify('019mr8mf4r', {
name : 'Achilles',
email : 'achilles@segment.io',
subscriptionPlan : 'Premium',
friendCount : 29
});
analytics.identify('{{my.segmentioID:default=
019mr8mf4r}}', {
name : '{{my.segmentioName:default=
Achilles}}',
email : '{{my.segmentioEmail:default=
achilles@segment.io}}',
subscriptionPlan : '{{my.segmentioSubscriptionPlan:default=
Premium}}',
friendCount : {{my.segmentioFriendCount:default=29}}
});
Or
{{my.segmentioJavaScript}} which just refers to the entire tracking code.
I would also stick with text tokens, and avoid rich text tokens in this case. With a rich text token, the values will be filtered through and possibly changed, especially with JavaScript or PHP. Even though this means one line and less pretty code, it's worth sticking with text tokens for inserting code.
If you're trying to change the tracking code with dynamic snippets, I would recommend you place the JavaScript in tokens. Because snippets are rich text, your code will be filtered out and broken if you try to use snippets without text tokens.
So you could have:
Segment 1: {{my.segmentioTrackingCode1}}
Segment 2: {{my.segmentioTrackingCode2}}
Snippets/nonsnippets aren't the problematic part, the rich text fields are where there's danger with abnormal HTML.
Bonus points:
JavaScript thrown into a random element in your page is poor development practice. It should go in the <head> or at the end of the <body>. I like to place a few extra empty tokens in the <head> and in the appropriate spot in the end of the <body> for uses like this. That way you can decide later that you want some JS/CSS and put it in the proper place without having to change every single template and reapprove every single landing page.
I like:
{{my.universalCSS1}}
{{my.universalCSS2}}
{{my.universalHeadJS}}
{{my.universalBodyJS}}
Then you can also define a top-level campaign folder with the tokens and override them on individual programs or lower-level campaign folders later on.
Best,
Edward Unthank
Marketing Operations Specialist
Yesler