How It Works
Conversion tracking allows you to measure the success of your email campaigns based on actions taken on your website (e.g., purchases or sign-ups). You can enable this feature under "Email Settings" → "Tracking". There, you will receive a custom JavaScript snippet to embed on your target page (e.g., the order confirmation page) and initialize with your account ID.
To transmit goal completions and detailed product data (such as price, name, and quantity), several function calls are available. These are modeled after Google Analytics tracking, making it simple to send comprehensive purchase details and order amounts to your reports.
Important Note on Cookie Tracking:
When a recipient clicks a link in your email, a tracking cookie valid for 30 days is placed in their browser. A conversion is only registered and credited if this cookie is active. If a conversion occurs after 30 days or in a cookie-restricted environment (such as incognito mode or a different device), it cannot be tracked or attributed to the email.
1. Embedding and Initializing the Snippet
Insert the following JavaScript snippet into the source code of your target page. Replace the placeholder 'Your ID' with your actual Newsletter2Go account ID:
<script id="n2g_script">
!function(e,t,n,c,r,a,i){e.Newsletter2GoTrackingObject=r,e[r]=e[r]||function(){(e[r].q=e[r].q||[]).push(arguments)},e[r].l=1*new Date,a=t.createElement(n),i=t.getElementsByTagName(n)[0],a.async=1,a.src=c,i.parentNode.insertBefore(a,i)}(window,document,"script","https://static.newsletter2go.com/utils.js","n2g");
n2g('create', 'Your ID');
</script>
2. Creating Transaction and Product Data
To capture e-commerce data, first initialize a transaction object (the order). A transaction requires at least a unique transaction ID (id) along with other overall order details:
n2g('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'Store', // Affiliation or store name.
'revenue': '11.99', // Grand Total.
'shipping': '5.00', // Shipping cost.
'tax': '1.29' // Tax amount.
});Optionally, you can add one or more items (products) to the transaction. Ensure that the transaction is created first and that the item's id matches the transaction ID exactly:
n2g('ecommerce:addItem', {
'id': '1234', // Transaction ID. Required.
'name': 'Product Name', // Product name. Required.
'sku': 'DD23444', // SKU/code.
'category': 'Category', // Category or variation.
'price': '11.99', // Unit price.
'quantity': '1' // Quantity.
});Note: Since these are JavaScript functions, they must be wrapped within appropriate <script> tags if added directly to HTML.
3. Sending the Conversion Data
Once the transaction and optional products have been defined, the conversion data must be sent to Newsletter2Go. This is typically done automatically (e.g., via the page's onload event or an onclick action):
n2g('ecommerce:send');
At this moment, the data is transmitted and matched to your mailing. You can view the tracked conversions directly within the reports of the respective email campaign.
