How to Implement Link Tracking in Your EDS
Adding automatic link tracking to your Email Design System (EDS) ensures you can measure email performance effectively. Depending on your requirements, you can choose different approaches for link tracking—ranging from simple hardcoded values to leveraging the powerful render_context
object for dynamic tracking.
This article explores three key methods to implement link tracking in your EDS, each offering different levels of flexibility and abstraction.
1. Hardcoded Tracking Parameters
The simplest way to add tracking parameters is to hardcode them directly into your component templates. This ensures that every link includes consistent tracking data.
Example:
Assuming your component has a field:
liquid variable | type |
---|---|
url | url |
<table>
<tr>
<td>
<a href="{{url}}?utm_source=emailshepherd&utm_medium=email&utm_campaign=example_campaign">Click me</a>
</td>
</tr>
</table>
While easy to implement, this approach is not flexible. Marketers cannot customize the tracking parameters, and maintaining consistency across multiple components requires manual updates.
2. Using Fields for Tracking Parameters
For more flexibility, you can define fields for each tracking parameter. This allows marketers to customize tracking values directly in the editor.
Example:
Assuming your component has fields:
liquid variable | type |
---|---|
url | url |
utm_source | text |
utm_medium | text |
utm_campaign | text |
<table>
<tr>
<td>
<a href="{{url}}?utm_source={{utm_source | url_encode}}&utm_medium={{utm_medium | url_encode}}&utm_campaign={{utm_campaign | url_encode}}">Click me</a>
</td>
</tr>
</table>
Benefits:
- Marketers can adjust tracking values for individual components or campaigns.
- Using the url_encode filter ensures that parameters are properly encoded for URLs.
Consideration:
- This approach may increase complexity for marketers who are unfamiliar with tracking parameters.
3. Using the render_context
Object for Automatic Tracking
The render_context
object provides detailed metadata about the project, email, and components being rendered. This metadata can be leveraged to generate tracking parameters automatically, offering granular insights into user interactions.
What Can You Track?
With the render_context object, you can dynamically track clicks based on:
- Projects: Identify the project that sent the email using
render_context.project.name
orrender_context.project.id
. - Emails: Pinpoint the exact email with
render_context.email.name
orrender_context.email.id
. - Components: Track interactions with individual components using
render_context.component_instance.component_name
,render_context.component_instance.component_id
, or even specific instances withrender_context.component_instance.id
.
This level of granularity makes it possible to analyze performance at multiple levels—whether you’re comparing projects, evaluating individual email performance, or testing the effectiveness of specific components.
Example:
Assuming your component has a field:
liquid variable | type |
---|---|
url | url |
<table>
<tr>
<td>
<a href="{{url}}?utm_source={{render_context.project.id}}&utm_medium=email&utm_campaign={{render_context.email.name | url_encode}}">Click me</a>
</td>
</tr>
</table>