i am trying to reset values of variable in google tag manager when particular tag fires
example:
action : add-to-cart
when 'add to cart' button is clicked then via datalayer i am pushing product data to gtm. this data i am storing in different variable such as - productid, productname ,productprice.
now when add to cart button hits then this variables will fill with data.
after that i have created one tag which sends this variable to 3rd party site via tag.
tag name : send-data-to-3rd-partysite
tag type : custom html
tag trigger - productprice does not contain undefined.
it means when productprice does not contains undefined then this tag should fire. (at start it contains undefined )
but problem is that when one 'add to cart' button is hits then the variable contains those product data for entire session and when another add to cart button hits then the data is replaced by new one. problem is here that 'send-data-to-3rd-partysite' fired when productprice contains some value. it does not fires becuase of productprice is not undefined.
so what i want is when 'send-data-to-3rd-partysite' tag fires then 'productprice' variable should be reset or clear.
i tries below code in send-data-to-3rd-partysite tag but did not work
<script>
...
window.google_tag_manager[{{productprice}}].dataLayer.reset();
<script>