We’re excited to announce a significant update to the SealMetrics pixel, designed to improve functionality and give users more flexibility in tracking events. This article outlines the differences between the old and new pixels, explains why you should update, and provides detailed implementation examples.
Why Update to the New Pixel?
The new SealMetrics pixel introduces several improvements over the previous version:
Improved Customization: The new pixel allows you to control whether a pageview event is triggered automatically when tracking conversions or micro-conversions. This provides more accurate event tracking, especially when a pageview should not be logged.
Future Updates: The old pixel will no longer receive updates or support. To take advantage of ongoing enhancements and new features, we recommend transitioning to the new version.
Enhanced Error Handling: The new pixel includes better error reporting for script loading issues, ensuring smoother implementation.
Comparison: Old Pixel vs. New Pixel
Old Pixel
Here is an example of the old pixel:
<script>
/* SealMetrics Tracker Code */
var oSm = window.oSm || {};
oSm.account = 'YOUR-ACCOUNT-ID';
oSm.event = 'pageview';
oSm.use_session = 1;
!function(e){var t="//app.sealmetrics.com/tag/tracker";window.oSm=oSm,window.smTrackerLoaded?sm.tracker.track(e.event):Promise.all([new Promise(function(e){var n=document.createElement("script");n.src=t,n.async=!0,n.onload=function(){e(t)},document.getElementsByTagName("head")[0].appendChild(n)})]).then(function(){sm.tracker.track(e.event)})}(oSm);
/* End SealMetrics Tracker Code */
</script>
When implemented, this version automatically triggers a page view event but lacks flexibility in configuring specific event-tracking behavior.
New Pixel
The new pixel simplifies configuration and adds advanced options for event tracking. Here’s the updated version:
Default Pageview Tracking
<script>
/* SealMetrics Tracker Code */
(function() {
var options = {
account: 'YOUR-ACCOUNT-ID',
event: 'pageview',
use_session: 1,
};
var url="//app.sealmetrics.com/tag/v2/tracker";
function loadScript(callback){
var script=document.createElement("script");
script.src=url;
script.async=true;
script.onload=function(){
if(typeof callback==="function"){
callback();
}
};
script.onerror=function(){
console.error("Error loading script: "+url);
};
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript(function(){
options.id=Math.floor((Math.random()*999)+1);
if(window.sm){
var instance=new window.sm(options);
instance.track(options.event);
} else {
console.error("sm2 plugin is not available");
}
});
})();
</script>
Tracking Conversions with the New Pixel
One of the main differences in the new pixel is how conversion events are handled. By default, the new pixel does not trigger a pageview event when tracking conversions. This behavior can be adjusted based on your needs.
Example 1: Conversion Without Pageview
To track a conversion without logging a pageview, set ignore_pageview
to 1
:
<script>
/* SealMetrics Tracker Code */
(function() {
var options = {
account: 'YOUR-ACCOUNT-ID',
event: 'conversion',
label: 'purchase',
ignore_pageview: 1,
use_session: 1,
};
var url="//app.sealmetrics.com/tag/v2/tracker";
function loadScript(callback){
var script=document.createElement("script");
script.src=url;
script.async=true;
script.onload=function(){
if(typeof callback==="function"){
callback();
}
};
script.onerror=function(){
console.error("Error loading script: "+url);
};
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript(function(){
options.id=Math.floor((Math.random()*999)+1);
if(window.sm){
var instance=new window.sm(options);
instance.track(options.event);
} else {
console.error("sm2 plugin is not available");
}
});
})();
</script>
Example 2: Conversion with Pageview
If you prefer to include a page view event along with the conversion, simply omit the ignore_pageview
parameter:
<script>
/* SealMetrics Tracker Code */
(function() {
var options = {
account: 'YOUR-ACCOUNT-ID',
event: 'conversion',
label: 'purchase',
use_session: 1,
};
var url="//app.sealmetrics.com/tag/v2/tracker";
function loadScript(callback){
var script=document.createElement("script");
script.src=url;
script.async=true;
script.onload=function(){
if(typeof callback==="function"){
callback();
}
};
script.onerror=function(){
console.error("Error loading script: "+url);
};
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript(function(){
options.id=Math.floor((Math.random()*999)+1);
if(window.sm){
var instance=new window.sm(options);
instance.track(options.event);
} else {
console.error("sm2 plugin is not available");
}
});
})();
</script>
Summary
The new pixel provides greater flexibility and customization options.
Users are encouraged to update to the new pixel, as the old version will no longer be updated or supported.
By default, the new pixel does not trigger a pageview for conversion events, but this behavior can be modified.
For any questions or assistance with updating your pixel, please get in touch with our support team.