-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
analytics.track JS appended to API responses breaks some implementations #194
Comments
Hi @minutiae , Thank you for the report. This sounds unintentional on our end as the content returned ought to just be as defined by contents of your template file ( Is your script running in a certain scenario? Such as following an add to cart action? Thank you for the added details. |
I've noticed in my local environment the script tag does not get appended, only in production. Yes, this follows an add to cart call from stencil utils. I thought perhaps this might occur only on the call following the add to cart call as a kind of queued message that needs to get out once, so I tried calling get cart a second time inside of the callback of the initial get cart call but both responses contain the script tag. Here is what my code looks like now that I've put in a temp fix to strip out the <script> tag @bc-jz ...
|
Thank you for the added details. I will be digging into this further but we do have an idea about where to look now. I will be getting back to you once I have some more information. |
Hi @minutiae, I just wanted to let you know I am still working on this. Things have been delayed due to the holidays and I have also not been able to reproduce this same issue on my own store. I am assuming I am doing something wrong. Could you clarify the following when you get a chance? The custom template file that you have at
? One of the teams related to the changes in this area should be back this week which will help me to dig further. Thank you for your patience in the meantime. |
@bc-jz That's correct, with a blank line following it since my editor appends a single blank line automatically.
|
@bc-jz I'm not sure if these two are connected, but one thing that may cause some differing behavior in stores is whether google analytics enhanced ecommerce tracking is turned on, I believe that is what controls settings.data_tag_enabled on the theme side. Could be that the tracking info being appended to my requests are contingent on that being on (it is on for our store), but I could be wrong. Just a thought |
For some time I've used
utils.api.cart.getContent({ template: 'custom/json/cart-product-ids' ... }
with the following code in that template
{{ json cart.items }}
So I can take the response inside the callback of utils.api.cart.getContent and parse json to get that cart contents.
Sometime yesterday the server started appending a <script> tag the end of the response with analytics.track('Product Added'... and so on inside which broke our site/ability to put things in the cart since the script is trying to parse the response as JSON.
Is there some way we can send an option parameter to ask for a json response (vs html) or somehow as the library here to not append that script tag as if the response were HTML? If this exists in the options parameter now, it would be great to see some explanation of what those options are in the docs since
https://developer.bigcommerce.com/stencil-docs/ZG9jOjIyMDcyMA-stencil-utils#get-cart
Thanks
The text was updated successfully, but these errors were encountered: