Reputation: 11
I am trying to save this Custom Javascript Variable within Google Tag Manager and return this error each time:
<script type="text/javascript">
sendinblue.identify('$_POST['_username']',{
'PRENOM': '$_POST['customer_checkout[data][firstname]']',
'NOM' : '$_POST['customer_checkout[data][lastname]']'
});
</script>
Google tag manager tell me : Parse error. ',' expected.
Do you have an idea ?
Thank you for your help
Joris
Upvotes: 1
Views: 1483
Reputation: 8736
Problem is that your snippet contains PHP code $_POST['_username']
, $_POST['customer_checkout[data][firstname]']
,$_POST['customer_checkout[data][lastname]']
. Your custom Javascript variable should contain only JS without any server-side languages
UPDATE
One of the ways of passing data to GTM:
If you have this values stored on the website, then on your website you should create hidden inputs:
<input value="$_POST['_username']" id="hiddenUsername"/>
<input value="$_POST['customer_checkout[data][firstname]']" id="hiddenFirstname"/>
<input value="$_POST['customer_checkout[data][lastname]']" id="hiddenLastname"/>
And then in GTM you can read data from this inputs:
sendinblue.identify(document.getElementById('hiddenUsername').value,{
'PRENOM': document.getElementById('hiddenFirstname').value,
'NOM' : document.getElementById('hiddenLasttname').value
});
Upvotes: 1