Thanks. I modified it like this,
$gtm_data->{'email'}=$_SESSION['userid'];
$gtm_data->{'campaign'}=$_SESSION['$campaign'];
But phpStorm has an issue with the $gtm still.
This code is in the model.
I am creating the gtm_data struct in the main controller with $gtm_data = new stdClass();
How can I just declare gtm_data as a Global so every module has access to it?
proof that an old dog can learn new tricks