Skip to main content

How to Add Custom Metadata and URL Parameters to Your eCardWidget Embed

Capture campaign IDs, transaction references, and other custom tracking data directly into your eCardWidget logs, exports, and integrations.

Tim Badolato avatar
Written by Tim Badolato
Updated over a week ago

When embedding an eCardWidget on your website, you may want to pass along additional metadata such as campaign identifiers, transaction IDs, or test flags. This information is then included in your eCard Logs, CSV exports, and any connected integrations (e.g., webhooks or Zapier).

There are two common approaches:


1. Hardcoding Custom Metadata into Your Embed

If you have static values you want to include with every submission, you can hardcode them into the window.ecw_merge_tags object before your widget script. For example:

<script> 
window.ecw_merge_tags = {
'ecardwidget_id_w2z2hvzc9ct': {
'track_this': '123',
'test': 'more info'
}
};
</script>

<script type="text/javascript" src="https://app.ecardwidget.com/embed/widget/w6v62rn95yq"></script>
<div id="ecardwidget_id_w6v62rn95yq"></div>

In this example:

  • The widget with ID ecardwidget_id_w2z2hvzc9ct will always log track_this=123 and test=more info.

  • These values are automatically included in eCard submissions.


2. Capturing URL Parameters as Metadata

In many cases, you’ll want your widget to capture dynamic information from the URL—such as transaction IDs (TRANSACTIONID=xyz123) or campaign sources (CAMPAIGN_ID=abc456). You can extend the script to automatically pull in all URL parameters and merge them into your metadata.

Here’s the recommended snippet:

<script> // Function to grab all URL parameters into an object function 
getUrlParams() {
const params = {};
const searchParams = new URLSearchParams(window.location.search);
for (const [key, value] of searchParams.entries()) {
params[key] = value;
}
return params;
}
// Your hardcoded defaults
const hardcoded = { 'track_this': '123', 'test2': 'test asdf asf dsa' };

// Merge URL params with hardcoded values
window.ecw_merge_tags = {
'ecardwidget_id_w2z2hvzc9ct': {
...getUrlParams(),
...hardcoded
}
};
</script>

<script type="text/javascript" src="https://app.ecardwidget.com/embed/widget/w6v62rn95yq"></script>
<div id="ecardwidget_id_w6v62rn95yq"></div>


How It Works

  • Any URL parameters (e.g., ?TRANSACTIONID=xyz123&SOURCE=email) will be automatically captured.

  • These parameters are merged with your hardcoded values.

  • The final metadata is included in Logs, Exports, and Integrations.


Best Practices

  • Use descriptive parameter names (e.g., campaign_id, transaction_id) for clarity.

  • Ensure parameters are properly URL-encoded when linking.

  • Decide whether hardcoded values should override URL parameters or not (adjust the merge order in the code as needed).


By combining static values with dynamic URL-based tracking, you gain complete flexibility in how your eCardWidget submissions are tagged and analyzed.

Did this answer your question?