Posts tagged with javascript

With the script below, I find a number of keywords with AdWordsApp.keywords() based on some parameters. Once these words are found, they must be paused.

My question is the following: How can I use the same list of ExactKeywords, that I have already found, to activate the same keyword in another campaign with a different name than CampaignName?


   var Exact_CampaignName = "CampaignName_1";          function main() {       // Getting list of keywords with cliks       var kw_Conv_Exact = AdWordsApp.keywords()         .withCondition("Click >= 50")         .withCondition("Status = ENABLED")         .withCondition(Exact_CampaignName)         .get();                      // Get Keywords from Campaigns_1       var ExactKeywords = [];       while (kw_Conv_Exact.hasNext()) {         var kw_exact = kw_Conv_Exact.next();         ExactKeywords.push(kw_exact);                       // Pause exaxt keywords.         for(var i in ExactKeywords) {           ExactKeywords[i].pause();         }   //But how do I enable the same keywords from var ExactKeywords = [] but in another campaign_2???      } 


Thanks in advance

I have a script that shows 10 most clicked keywords, their average CPC and conversions. While previewing the script it works fine. But when I send it to my email, only last row of the 10 rows shows. What is wrong here?

function main() {   var keywords = AdsApp.keywords()       .orderBy("Clicks DESC")   //  .orderBy("Impressions DESC")       .forDateRange("THIS_MONTH")       .withLimit(10)       .get(); Logger.log("10 most clicked keywords");   while (keywords.hasNext()) {     var keyword = keywords.next();     content = keyword.getText() + " | Clicks: " + keyword.getStatsFor("THIS_MONTH").getClicks() + " | CPC: " + keyword.getStatsFor("THIS_MONTH").getAverageCpc().toFixed(2) +      " | Conversions: " + keyword.getStatsFor("THIS_MONTH").getConversions();   }    MailApp.sendEmail({             to: 'myemail@myemail.com',             subject: "10 most clicked keywords",             htmlBody: content });      }

I'm trying to set html content of a new element but when I check to see if slot.getHtml() gives me the html element (set below), it shows an empty string. Any idea why this could be happening?

var slot = googletag.defineSlot('/1234567/sports', [160, 600], 'ozge')   .addService(googletag.companionAds())   .addService(googletag.pubads())   .addService(googletag.content()); googletag.content().setContent(slot, '<h2>Custom content in ad slot.</h2>') 

I use the code snippet in this link to view the newly defined slot: https://gist.github.com/rdillmanCN/a70ec955d9a982127fefadabe8b898b5

I use “google-ads-api” to manage google ads. And api needs “customer_account_id” to initialization. However, I Couldn’t found how to get “customer_account_id” programmatically from user.

I used “react-google-login” in front-end, but there is no “customer_account_id” in the response. What is the best way to get customer_account_id?

I implemented a custom script in tankyou page in my woocommerce store to track google ads conversions. This is my implementation:

add_action( "woocommerce_thankyou", "pixel_analytics_conversion_track_script", 20 ); if ( ! function_exists( 'pixel_analytics_conversion_track_script' ) ) {     function pixel_analytics_conversion_track_script($order_id){         if ( $order_id > 0 ) {             $order = wc_get_order( $order_id );             if ( $order instanceof WC_Order ) {                 $order_id               = $order->get_id(); // order id                 $order_key              = $order->get_order_key(); // order key                 $order_total            = $order->get_total(); // order total                 $order_currency         = $order->get_currency(); // order currency                 $order_payment_method   = $order->get_payment_method(); // order payment method                 $order_shipping_country = $order->get_shipping_country(); // order shipping country                 $order_billing_country  = $order->get_billing_country(); // order billing country                 $order_status           = $order->get_status(); // order status                 ?>                 <script type="text/javascript">                     jQuery(document).ready(function( $ ){                         console.log('PURCHACE EVENT');                         /* Track conversion on facebook Pixel */                         fbq('track', 'Purchase',                         {                             value: <?php echo $order_total ?>,                             currency: "<?php echo $order_currency ?>"                         });                                              /* Track conversion on Google Ads */                         gtag('event', 'conversion',                          {                              'send_to': 'AW-693771414/0MhwCMa9rLYBEJa56MoC',                              'value': <?php echo $order_total ?>,                              'currency': "<?php echo $order_currency ?>",                              'transaction_id': "<?php echo $order_id ?>"                         });                     });                 </script>                 <?php             }         }     } } 

The code works very well but some data is not precise and I think that probably the code above duplicates conversion if user goes to thank you page twice. We have an order confirmation email that has a link to the thankyou page of woocommerce.

As you can see Im sending the transaction_id parameter, so my question:

If the user loads twice or N times the thank you page the conversion will appear dupplicated in Google ads even if you send the transaction_id parameter?