Data Layer and Javascript object = error

(Cédric) #1

Hello. I am trying to get a javascript object that is pushed in the datalayer.

this is the event push:

    'event': 'myevent',

and this is the tag:

<script type="text/javascript">
var myobj = {{Obj}};

i have created a variable “Obj” for the object “obj”.

But i have an error:

SyntaxError: missing ] after element list
note: [ opened at line 2, column 12

Thank you for your help.

(Cédric) #2


inside the code of the website, the tag appear like this:

<script type="text/javascript">
var myobj = [object Object];


Cheers @c3do

I’ve created a pull request to be able to assign objects through Custom HTML. Initially, it was only supported to add strings

(Cédric) #4

Great! i will use JSON or a javascript variable as a temporary solution. Thank you very much thomas.

(Fabian Dellwing) #5

I created a patchfile for you: customhtmlobjfix.patch (45.1 KB)

You can apply it to the tag manager with git apply customhtmlobjfix.patch.