I'm setting up a new form tracking system for my website (the form framework is Gravity forms).
The codebase consists in a parent theme, plus 3 child theme (one for the main website, one for the shop, and another for another branch of the business).
I have a general class in the parent theme which sets up a basic tracking for every gravityforms form using the gform_after_submission
filter.
class CustomGF { // ... some vars public function __construct() { // Events tracking add_filter( 'gform_after_submission', [$this, 'track_conversion'], 10, 2 ); // ...other construct functions } public function track_conversion($entry, $form) { $trackingArgs = [ // ... some arguments ]; $trackingArgs = apply_filters('ll/tracking_args', $trackingArgs); // ... tracking code here } }
After the basic setup, for some specific forms I want to alter the tracking arguments.
So in my child theme I have an additional class which uses the `gform_after_submission_{form_id}' filter to alter the behavior of the tracking for some forms:
class GFChild extends CustomGF { public function __construct() { add_action( 'gform_after_submission_9', [$this, 'submission_business_visit'], 10, 2); } public function submission_business_visit($entry, $form) { add_filter('ll/tracking_args', function() { $newArgs = [ // ... new args here ]; return $newArgs; } } }
But apparently the add_filter('ll/tracking_args')
call in the child theme is not working. Any advice on how to make it work?
Thanks!