Facebook started adding query param for tracking - Remove with mod_rewrite so as not to interfere with whereRecordNumberInUrl

6 posts by 5 authors in: Forums > Off Topic / Other
Last Post: May 14, 2019   (RSS)

By Steve99 - November 7, 2018

Hi all,

We noticed that Facebook recently started automatically adding a tracking query param to links shared on their platform. It's "fbclid" followed by a long alphanumeric value.

The problem we noticed was if the query param value ended with a numeric value it would interfere with the function whereRecordNumberInUrl which is used for multi record section detail pages.

We used mod_rewrite to remove this query param so as not to interfere with the above referenced function. We do use the permalinks plugin on our sites and added the following code right before "Pass URL parameter to permalinks dispatcher":

## remove facebook tracking query param fbclid
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=[^&]+&?(.*)$ [NC]
RewriteRule ^/?(.*)$ /$1?%1%2 [R=301,NE,L]

Feedback on this topic is certainly welcome.


By Dave - November 8, 2018

Thanks Steve, 

Looks like that's a new parameter added by Facebook recently.  I see there's a lot of posts returned by google from the last few days about it.

You can update getLastNumberInUrl() in /lib/viewer_functions.php to ignore that with the following change: 

  • Open /lib/viewer_functions.php
  • Search for: action_ref_map
  • Add the code in red: 'action_ref_map','fbclid', // additional facebook parameters

And that should fix it for whereRecordNumberInUrl() as well.  

Let me know if that works for you and we'll get it in the next release as well.  Thanks!

Dave Edis - Senior Developer

By Steve99 - November 8, 2018

Ah, got it, the remove fields array. I see other auto tag params in there too, perfect. Much better than removing with mod_rewrite.

Thanks Dave!


By csdesign - December 18, 2018

Wish I had thought of checking the forum sooner to solve this fbclid issue!!  Huge help. Thank you so much!! 

By (Deleted User) - February 25, 2019

I agree. I also looked at the wrong time. Thanks for the information.