How to Avoid Missing Ad Click ID on iPhone Using Matomo

By JoeVu, at: 11:03 Ngày 19 tháng 12 năm 2024

Thời gian đọc ước tính: 5 min read

How to Avoid Missing Ad Click ID on iPhone Using Matomo
How to Avoid Missing Ad Click ID on iPhone Using Matomo

How to Avoid Missing Ad Click IDs on iPhone Using Matomo

With iOS 17’s Link Tracking Protection stripping common tracking parameters like dclid, msclkid, and others, maintaining accurate ad tracking has become more challenging. A recent case with one of our clients revealed significant data loss in Matomo, despite consistent data in Google Ads and Shopify.

To address this issue, we devised a custom solution by renaming ad parameters and restoring them in Matomo’s JavaScript tracking. This method bypasses iOS’s link tracking removal while preserving data integrity. Here’s how we solved the problem.

 

Understanding the Challenge

Link Tracking Protection in iOS 17 automatically strips known tracking parameters from URLs. Affected parameters include:
 

  • gclid – Google AdWords / Analytics
     
  • dclid – Google Display Network
     
  • foclid – Facebook Advertising
     
  • twelkd – Twitter Advertising
     
  • msclkid – Microsoft Advertising
     
  • mc_eid – Mailchimp
     
  • igshid – Instagram
     

While these changes enhance user privacy, they disrupt marketing attribution workflows, leading to incomplete data in analytics platforms like Matomo.

 

Our Solution

To bypass iOS 17’s restrictions, we devised a two-part strategy:
 

  1. Customize Parameter Names in Ad URLs
     
  2. Restore Original Parameter Names in Matomo Tracking Code
     

This ensures that tracking parameters are not stripped by iOS while preserving their functionality in Matomo.

 

1. Customize Parameter Names in Ad URLs

Modify your ad URLs to replace the default tracking parameters with custom names that iOS does not recognize as tracking identifiers.

Example Parameter Mapping:
 

  • gclid becomes customMatomoGclid
     
  • dclid becomes customMatomoDclid
     
  • foclid becomes customMatomoFoclid
     
  • twelkd becomes customMatomoTwelkd
     
  • msclkid becomes customMatomoMsclkid
     
  • mc_eid becomes customMatomoMc_eid
     
  • igshid becomes customMatomoIgshid
     

Updated Ad URL Example:

https://www.glinteco.com/?customMatomoGclid=12345&customMatomoFoclid=67890


By replacing these parameters with custom names, they are not flagged or removed by iOS’s Link Tracking Protection.

 

2. Restore Original Parameter Names in Matomo Tracking Code

Use JavaScript to map the custom parameters back to their original names before sending them to Matomo.

Custom Matomo JavaScript Example:

// Capture URL parameters
var urlParams = new URLSearchParams(window.location.search);

// Map custom parameters back to original names
var paramsMapping = {
    'customMatomoGclid': 'gclid',
    'customMatomoDclid': 'dclid',
    'customMatomoFoclid': 'foclid',
    'customMatomoTwelkd': 'twelkd',
    'customMatomoMsclkid': 'msclkid',
    'customMatomoMc_eid': 'mc_eid',
    'customMatomoIgshid': 'igshid'
};

// Loop through the mapping and send to Matomo
for (const [customParam, originalParam] of Object.entries(paramsMapping)) {
    var paramValue = urlParams.get(customParam);
    if (paramValue) {
        _paq.push(['setCustomVariable', 1, originalParam, paramValue, 'visit']);
    }
}

 

What This Does:
 

  • Extracts custom parameters from the URL.
     
  • Maps them back to their original names.
     
  • Sends the data to Matomo for accurate tracking and attribution.

 

Implementation Steps

  1. Update Ad Campaigns: Modify all active campaign URLs in Google Ads, Facebook, Microsoft Ads, and other platforms to use custom parameter names.
     

  2. Update Matomo Tracking Code: Add the custom mapping logic to your website’s JavaScript tracking code.
     

  3. Test the Tracking: Verify the functionality by clicking on test ads and checking that Matomo receives the correct parameters.

 

Why This Solution Works

 

  • Avoids Parameter Stripping: Custom names prevent parameters from being identified and removed by iOS’s tracking protection.
     

  • Maintains Data Integrity: By restoring parameters in Matomo, the data remains accurate and actionable.
     

  • Seamless Integration: This method works across all major ad platforms without disrupting other tracking systems.

 

Conclusion

iOS 17’s privacy updates present challenges, but with a proactive approach, you can maintain accurate ad tracking. By customizing parameter names and restoring them in Matomo, you can navigate these changes effectively while safeguarding your campaign attribution.

Would you like assistance implementing this solution or exploring additional tracking strategies? Let us know!

 


Liên quan

Theo dõi

Theo dõi bản tin của chúng tôi và không bao giờ bỏ lỡ những tin tức mới nhất.