Posts under category google-ads-api

I'm working with the Google Ads API to retrieve campaign simulations for a specific date range. So far whenever I try to filter for a date range outside of the "current simulation" I receive no results. The "current simulation" is the default simulation that shows on the platforms websites simulation tool.

Here's my current code snippet (relevant portion):

try:     # Get the GoogleAdsService     googleads_service = client.get_service("GoogleAdsService")     # Construct the query     query = f"""         SELECT             campaign_simulation.campaign_id,             campaign_simulation.type,             campaign_simulation.start_date,             campaign_simulation.end_date,             campaign_simulation.budget_point_list.points,             campaign_simulation.cpc_bid_point_list.points,             campaign_simulation.target_cpa_point_list.points,             campaign_simulation.target_impression_share_point_list.points,             campaign_simulation.target_roas_point_list.points         FROM             campaign_simulation         WHERE             campaign_simulation.campaign_id = {campaign_id}      """     # Execute the search request     response = googleads_service.search_stream(customer_id=customer_id, query=query) 

I've attempted filtering based on campaign_simulation.start_date and campaign_simulation.end_date within the WHERE clause, but it only retrieves the current simulation. On the platforms website you can change the range to be any 7 day period after the current date, and this is what I expect to be able to do from the API as well.

Wanting to track 'Add to Cart' clicks on a WooCommerce store & Google Ads tell me I need to call gtag_report_conversion when any 'Add to cart' button is clicked on the site.

Some buttons are a link <a href="... etc"> using class="add_to_cart_button" - see example page

While other buttons are a <button> tag using class="single_add_to_cart_button" - see example page

I see from Google's instructions that the structure for a link is:

<a onclick="return gtag_report_conversion('http://example.com/your-link');"href="http://example.com/your-link">Add To Cart</a>

And the structure for a <button> tag is:

<button onclick="return gtag_report_conversion('http://example.com/your-link')">Add To Cart</button>

How can I construct a function hook that will create the above link / button tag structure & would it be an action or filter hook? Also, is it possible to use the classes mentioned earlier to define which buttons on the site should be affected by this particular function. The documentation showing what action & filter hooks are available for WooCommerce is here.

I'm working on a Gatsby.js project that displays ads correctly in production, but not in localhost.

An iframe is supposed to be inserted into the Ad component via a script that is generated by the 'gatsby-browser.js' file. To facilitate this, I've also added another script in the 'gatsby-ssr.js' file to append Google Tags to the Window object, since I was having trouble doing this via the 'onClientEntry' function.

So far, I can generate the required Window objects, and append the script tag to the head tag in the HTML document, but still cannot generate the iframe.

Ad component

import React, { Component } from 'react' class Ad extends Component {   componentDidMount(){     const script=document.createElement('script')     script.src=`${adEmbedCodeURL}`     script.defer=true;     script.setAttribute("data-can-ad","true")     this.instance.appendChild(script)        }   render() {     return (     <div className=`${class-name}` ref={el => (this.instance = el)} >         <p>Advertisement</p>     </div>     )   } } export default AdMPU 

gatsby-browser.js

export const onClientEntry= () => { if (typeof __canGDPR == 'function') {      console.log('onClientEntry')     window.__canGDPR(function() {       console.log('onClientEntry - CANS')       var createScript = function(url, callback) {         var script = document.createElement('script');         script.src = url;         if (callback) {           script.onload = callback;          }document.getElementsByTagName('script')[0].appendChild(script);       };       createScript(`https://www.googletagmanager.com/gtag/js?id=${containerID}`);       window.dataLayer = window.dataLayer || [];       function gtag(){         window.dataLayer.push(arguments);       }gtag('js', new Date());       gtag('config', `${containerID}`);     }); }; } export const onRouteUpdate = () => {     console.log('onRouteUpdate'); if (typeof __canGDPR == 'function') {      window.__canGDPR(function() {       console.log('onRouteUpdate - CANS')       var createScript = function(url, callback) {         var script = document.createElement('script');         script.src = url;         if (callback) {           script.onload = callback;          }document.getElementsByTagName('script')[0].appendChild(script);       };       createScript(`https://www.googletagmanager.com/gtag/js?id=${containerID}`);       window.dataLayer = window.dataLayer || [];       function gtag(){         window.dataLayer.push(arguments);       }gtag('js', new Date());       gtag('config', `${containerID}`);     }); }; } 

gatsby-ssr.js

import React from 'react' export const onRenderBody = ({ setHeadComponents }) => {     setHeadComponents ([     <script       key="SGCCansAds"       src=`${adEmbedCodeURL}`     />,     <script        key="jQuery"        src="https://code.jquery.com/jquery-3.3.1.min.js"     />,     <script     key="gtm-script"     async     src=`https://www.googletagmanager.com/gtag/js?id=${containerID}`   />,   <script     key="gtm-initializer"     dangerouslySetInnerHTML={{       __html: `         window.dataLayer = window.dataLayer || [];         function gtag(){ window.dataLayer.push(arguments); }         gtag('js', new Date());         gtag('config', `${containerID}`);       `,     }}   />,   ]) } 

I have implemented AdMob Server Side Verification How to verify Admob Rewarded Video Ad on a server?

Everytime the user finishes watcing a rewarded ad, Google Server Makes a GET call to my Server. I verify the signature, then store an entry to my database.

To my surprise, I noticed a discrepancy between the number of API calls recorded and the impression count on the AdMob Panel.

This results in lesser earning than what I actually reward my user.

Server Logs:

ad_reward_audit.dart:52:7) 2024-07-31 00:00:00.000Z: 2 ad_reward_audit.dart:52:7) 2024-08-01 00:00:00.000Z: 3 ad_reward_audit.dart:52:7) 2024-08-02 00:00:00.000Z: 1 ad_reward_audit.dart:52:7) 2024-08-03 00:00:00.000Z: 2 ad_reward_audit.dart:52:7) 2024-08-04 00:00:00.000Z: 35 ad_reward_audit.dart:52:7) 2024-08-06 00:00:00.000Z: 6 ad_reward_audit.dart:52:7) 2024-08-07 00:00:00.000Z: 3 ad_reward_audit.dart:52:7) 2024-08-08 00:00:00.000Z: 5 ad_reward_audit.dart:52:7) 2024-08-09 00:00:00.000Z: 36 ad_reward_audit.dart:52:7) 2024-08-10 00:00:00.000Z: 28 

AdMob Panel:

Am I wrong to think that the number of impression should match the number SSV API call ?

If it should be the case, what other steps can I do to investigate this ? I am making loss at the moment do this issue as my rewards to user actually cost me actual money (Computing time cost on expensive GPU)

I am trying to implement Google Ads into my flutter app. I closely followed the implementation guides but when I start the app even though it says the ad successfully loaded it does not show up. Sometimes it flashes up for a second but immediately disappears afterwords. Does anyone have an idea what could be the problem?

    loadAd() {     BannerAd banner = BannerAd(       adUnitId: adUnitId,       request: AdRequest(),       size: AdSize.banner,       listener: BannerAdListener(           // Called when an ad is successfully received.           onAdLoaded: (ad) {         debugPrint('$ad loaded.');         setState(() {           _isLoaded = true;         });       },           // Called when an ad request failed.           onAdFailedToLoad: (ad, err) {         debugPrint('BannerAd failed to load: $err');         // Dispose the ad here to free resources.         ad.dispose();       }, )     );     banner.load();     setState(() {       _bannerAd = banner;     });   } 
 Widget build(BuildContext context) {     return _isLoaded         ? Container()         : Container(           alignment: Alignment.center,           child: SizedBox(             height: AdSize.banner.height.toDouble(),             width: AdSize.banner.width.toDouble(),             child: AdWidget(               ad: _bannerAd!,             ),           ),         );   }