Posts tagged with javascript

While working on WhatsApp Business Cloud API, I have to send an Image through WhatsApp. When I send that image I am getting a response as a sha256 base64 string and an imageId. I want to retrieve back that image using these credentials. I'm getting a URL when I make a get request with that image id. That URL is actually broken/invalid and I'm not getting the image back.

Response of the request is given below :

"messages": [               {                 "from": "918******6",                 "id": "wamid.HBgMOT*********EA",                 "timestamp": "1655978686",                 "type": "image",                 "image": {                   "mime_type": "image/jpeg",                   "sha256": "ian**********jM4k=",                   "id": "4**********7"                 }               }             ] 

I am using Google Ads to track purchase conversions on my Ecommerce website. When a user clicks on my Google Ad for a product and then makes the purchase and lands on the thank you page, the conversion event is triggered and sends google the data so that it knows that an order has been placed and it can track the conversion.

My problem is that EACH time that same thank-you page is loaded with that users order id token, it fires that script and Google tracks that as another conversion. This should only be happening once, this should only happen the first time the page is accessed with that order token.

Take this url below for example. A user saw my Google Ad and then clicked on it and purchased and then he landed on the thank you page. At this point it was tracked as a conversion. https ://mywebsite.com/purchase/thank-you/order/1001632bfd1c-2x5a-701t-1xs90a0a4444

Sometime later the same day or 20 days later, the user opens up the browser on his phone and that page reloads, or the user wants to check his browsing history and clicks on this url. As soon as he lands on it, the script will fire once again and count that as a conversion for the ad he originally clicked on.

Is there a way that I can make it so that the script only fires the first time a url loads? Merchants who are using Shopify simply wrap the conversion event script with {% If First_time_accessed %} in Liquid which is Shopify's language. This makes it so that even if the user reloads that same url, the script won't fire again to track that page visit as another conversion.

How do I do this type of logic if I am developing my site in ASP.net using C# MVC ? Is there some javascript I can wrap my event snippet with to make it work like Shopify does it? I have searched for this but keep only finding info on how to do it on Shopify. Note...I am not using Tag Manager, I want to just leave the event snippet on my page without having to set up anything in tag manager.

Here is my script currently:

<!-- Global site tag (gtag.js) - Google Analytics -->   <script async src="https://www.googletagmanager.com/gtag/js?id=G-M3WT222222"></script> <script>     window.dataLayer = window.dataLayer || [];     function gtag() { dataLayer.push(arguments); }     gtag('js', new Date());     //conversion tracking for Google Analytics     gtag('config', 'G-M3WT222222');     //conversion tracking from Google Ads     gtag('config', 'AW-12057888501'); </script> <!-- Event snippet for MYwebsite Purchase conversion page --> <script>         gtag('event', 'conversion', {             'send_to': 'AW-12057888501/x0QzZp_vliJUHNC-B08Zx',             'value': @ViewBag.Display_subtotal,             'currency': '@ViewBag.Display_currencyAbbreviation',             'transaction_id': '@ViewBag.Display_invoiceNumber'         }); </script> 

This is an example of how Shopify does this. Notice the code is wrapped in some liquid code shown here {% if first_time_accessed %}

{% if first_time_accessed %} <!-- Event snippet for Purchases Shopify conversion page --> <script>   gtag('event', 'conversion', {   'send_to': 'AW-2035565011/frthgrt455_151f5rfc',   'transaction_id': '{{ order_number  }}'   }); </script> {% endif %} 

I'm integrating Google Ads Rest API.I want to pass an array of type UserIdentifier to a function where each object should only have one item only because it is required by this Google Ads API for example:

f([{hashedEmail: "xxxxxx"}, {hashedPhoneNumber: "xxxxxx"}]) // OK f([{hashedEmail: "xxxxxx", hashedPhoneNumber: "xxxxxx"}]) // Not Cool 

This example comes close but I only want to use the keys that are mentioned in Google Ads API UserIdentifier type.

Thanks in advance.

I have a question about manage items stock / outstock google ads I've tried to use Google Scripts - but it decision not matched for me, because page code site has often change by developers Google Ads API - is it decisions for my requirement? Someone use it for manage ads - for stop ads if items outstock?