xyNNN / GoogleTagManagerBundle

Google Tag Manager Bundle for Symfony 2
https://github.com/xyNNN/GoogleTagManagerBundle
GNU Lesser General Public License v3.0
27 stars 15 forks source link

Play nice with Nelmio/ApiDocBundle #20

Open jaymecd opened 7 years ago

jaymecd commented 7 years ago

Affected versions: 1.x & 2.x

ApiDocBundle (2.13.2) embeds full jQuery lib as js payload directly into the <head> section. This JS code contains following:

...
(f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close()
...

So GoogleTagManagerListener class (1.0.5 / 2.1.0) do not respect that and inject GTM into JS code, which is not real <body>.

Solution is to update regex from '/<body\b[^>]*>/' to '/<\/head>\s*<body\b[^>]*>/'.

Unfortunately could not provide PR right now, maybe later this week, if it won't be fixed earlier.