Posts tagged with javascript

I am using the below code sample from GTP docs to refresh the ad automatically in a specific time interval. But, the slot is cleared when it fetches a new ad and the response is empty. Is it possible to prevent clearing the slot until I get a successful response?

googletag.cmd.push(function() {   var REFRESH_KEY = 'refresh';   var REFRESH_VALUE = 'true';   googletag.defineSlot('/6355419/Travel',[728, 90], 'div-for-slot')       .setTargeting(REFRESH_KEY, REFRESH_VALUE)       .setTargeting('test', 'event')       .addService(googletag.pubads());   // Number of seconds to wait after the slot becomes viewable.   var SECONDS_TO_WAIT_AFTER_VIEWABILITY = 60;   googletag.pubads().addEventListener('impressionViewable', function(event) {     var slot = event.slot;     if (slot.getTargeting(REFRESH_KEY).indexOf(REFRESH_VALUE) > -1) {       setTimeout(function() {         googletag.pubads().refresh([slot]);       }, SECONDS_TO_WAIT_AFTER_VIEWABILITY * 1000);     }   });   googletag.enableServices(); }); 

I have a Wordpress page and I need to track all clicks as Google Ads conversion so I've found that I can use the entire page as a link with the following code:

<html>     <body onclick='window.location.href="http://google.com"'>     </body> </html>

Then I need to activate the Google conversion tag at every click and the conversion script are:

<!-- Event snippet for Solicitar cotação conversion page In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> <script>function gtag_report_conversion(url) {   var callback = function () {     if (typeof(url) != 'undefined') {       window.location = url;     }   };   gtag('event', 'conversion', {       'send_to': 'AW-ID/AWID',       'event_callback': callback   });   return false; }</script>

Ok, so please, how can I make every click count as a conversion?

Thank you very much.

I am using google-ads-api module in nodejs to connect with Google Ads API.

I am using this code block to get Customer

const customer = client.Customer({     customer_id: 'XXX-XXX-XXXX',     refresh_token: refreshToken, }) 

I have used XXX-XXX-XXXX, XXXXXXXXXX, XXXX-XXX-XXX format for customer_id but still it is returning this error

GoogleAdsFailure {   errors: [     GoogleAdsError {       error_code: [ErrorCode],       message: "Invalid customer ID ''."     }   ],   request_id: 'OcUdfalh_N0U4hTJUd6c6g' } 

Currently we are moving from google-ads-node package to google-ads-api.

The main problem that we can not retrieve detailed information about customers ads account.

The method Client.listAccessibleCustomers work just fine but it retrieve only following data

[ `customers/${customerID}`, `customers/${customerID}`, ... ] 

But we need all the data from the customer ads account

There is a file in package ServiceFactory which extends each exported class (place in a raw mode because it's huge)

There is a getter public get customers which retrieve some methods to get them, but there is also warning that you shouldn't use it in production, so how I should retrieve this info?

Even if I try to use it I've get the following error

    {        "errors": [            {              "error_code": {                "authorization_error": 24              },              "message": "The customer can't be used because it isn't enabled."          }        ]     } 

On google-ads-node there aren't any errors and we get the result, but they advice to move to google-ads-api

i need display multiple ads on one page with this code:

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> <div id="gpt-passback650x250"> <script> window.googletag = window.googletag || {cmd: []}; googletag.cmd.push(function() { googletag.defineSlot('/162717810/xxxxx/650x250', [650, 250], 'gpt-  passback650x250').addService(googletag.pubads()); googletag.enableServices(); googletag.display('gpt-passback650x250'); }); </script> </div> 

If i use this code twice or more on page, i get error: Exception in queued GPT command TypeError: Cannot read property 'addService' of null

Code must be same, customer want paste it to page via shortcode in cms. How to solve this? Thanks