I am trying to use the GAPro plugin to the (Licensed) JW Player to track video play statistics in Google Analytics (GA). I have added the plugin name and GA account information as specified in the GAPro doc:
This did not seem to have any effect and no event statistics were reported in GA. Watching the page using LiveHTTPHeaders I did not see the expected GA requests, so it looked like nothing was actually happening.
I then added the debug option which should overlay debug information on the video as it plays to show the messages being sent to GA:
As before, nothing was happening. I then looked at the generated code and noticed that the periods in the Flashvar names had been translated into underscores:
"plugins": "gapro-1", "gapro_accountid": "UA-1234567-8", "gapro_debug": "true"
This is the cause of the problem. The GAPro plugin is being loaded but it cannot find its parameters and so does not do anything.
To prove this was the problem I copied and pasted the generated code into a private post and changed the underscores to periods in the GAPro parameters. This then worked! The trace messages appeared overlaid on the video and I could see the HTTP requests going to the GA servers in LiveHTTPHeaders.
My question: Is there a way to escape the period in the Flashvar variable names such as “gapro.accountid” so that the period makes it through into the generated code?
“Flashavr” in the title should of course have been “Flashvar”…
As a workaround I added some code into vipers-video-quicktags.php to specifically check for the two Flashvar variable names I am interested in:
$flashvars = '"' . js_escape( $property ). '": "' . js_escape( $value ) . '"';
$isv_property = js_escape( $property ); if ( $isv_property == "gapro_accountid" ) $isv_property = "gapro.accountid"; if ( $isv_property == "gapro_debug" ) $isv_property = "gapro.debug"; $flashvars = '"' . $isv_property. '": "' . js_escape( $value ) . '"';
Not very elegant, but it works!
It’s an (annoying) feature of
parse_str()that I wasn’t aware of.
Note that variables cannot contain a DOT (.) in PHP. So, DOT will be replaced by underscore.
e.g. variables like “variable.something” will be converted into “variable_something”.
Fixed in v6.2.11.
- The topic ‘[Plugin: Viper’s Video Quicktags] Flashavr variable changes period to underscore in names’ is closed to new replies.