A marketing team requested that Freshy integrate TVSquared action tracking into the mobile buttons of their WordPress site to monitor key conversions such as “Click to Text,” “Click to Call,” and “Request Consultation.”
The task involved safely injecting multiple tracking codes, handling undefined parameters in the vendor’s script, and confirming that each button trigger executed correctly across desktop and mobile versions. The solution was implemented using custom JavaScript that fires a standardized tracking function on button click events, ensuring consistent data capture for TVSquared analytics.
Issue Background
The client’s marketing department provided tracking scripts from TVSquared (now InnovidXP) to be applied to specific mobile button interactions. These included:
- “Click to Call” buttons in the mobile header.
- “Click to Text” buttons for mobile users.
- “Request Consultation” CTA buttons throughout the site.
The tracking code contained placeholders such as:
<USERREF>
<REVENUE>
<PRODUCT>
<ACTIONID>
<PROMOCODE>
However, none of these values were defined or dynamically generated on the site. Without clarification, this would have caused the tracking calls to fail or return incomplete data.
Diagnosis
Freshy’s developer team reviewed the provided TVSquared documentation and confirmed:
- Most placeholders (
rev,prod,id,promo) were optional and could be replaced with empty strings. - The
<USERREF>parameter was also optional — intended for internal user IDs if available, but not required for the action tag to function. - The tracking code could be simplified to a base call with static parameter values.
After confirming requirements with the vendor’s documentation and the client’s marketing contact, the team decided to create a single reusable tracking function that could be called from multiple buttons with unique identifiers.
Resolution Steps
- Created a unified JavaScript tracking function
function fireTVSquaredTracking(actionName) {
var action = {
rev: '',
prod: '',
id: '',
promo: ''
};
console.log('Firing TVSquared Action:', actionName);
window.tvSquaredTrack(actionName, action);
}
This wrapper standardized the tracking code so that each button could call the same function with a unique actionName (e.g., kpi4, kpi5, kpi6).
- Attached click event listeners
Each button on mobile was updated to fire the appropriate event:
<a href="tel:555-555-5555" onclick="fireTVSquaredTracking('kpi4')">Click to Call</a>
<a href="sms:555-555-5555" onclick="fireTVSquaredTracking('kpi5')">Click to Text</a>
<a href="/contact/" onclick="fireTVSquaredTracking('kpi6')">Request Consultation</a>
The desktop header also contained a “Call” link, so the tracking code was extended there as well for consistency.
- Verified execution
Tested on multiple devices to confirm that allonclickhandlers executed properly. Used browser console logs and the network tab to verify tracking function calls. Coordinated with the marketing team to validate that data appeared in the TVSquared dashboard. - Optimized for future use
The script was structured to allow easy modification ofactionNamevalues if new buttons or KPIs are added later.
Final Outcome
- TVSquared tracking successfully fired for all targeted CTAs.
- The same code now handles desktop and mobile button clicks.
- No errors or undefined parameter warnings appeared in console logs.
- The client’s marketing team confirmed the tracking events were received correctly.
This implementation provided a robust and reusable structure for managing future tracking updates without the need for page-specific scripts.
Takeaways
This project demonstrates how to integrate vendor-provided tracking scripts safely within WordPress without hardcoding redundant code blocks.
- Always verify vendor documentation for optional vs. required parameters.
- Use wrapper functions to streamline repetitive code.
- Test on multiple devices to confirm JavaScript event consistency.
- Collaborate closely with marketing teams to validate analytics data post-deployment.
By building modular and maintainable tracking logic, Freshy ensured the client’s campaign tracking remained accurate and easy to expand.
Need Help Implementing Tracking or Analytics Integrations?
If your website needs campaign tracking or third-party analytics scripts integrated safely, Freshy’s WordPress developers can help you design reliable, lightweight solutions.
Contact us today to ensure your marketing data is captured accurately.