googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
295 stars 262 forks source link

membership_life_span seems to only be set to 540 when interacting with api #969

Closed austinkregel closed 9 months ago

austinkregel commented 11 months ago

Your client library and Google Ads API versions:

Your environment:

================= PHP GENERAL INFORMATION
phpinfo()
PHP Version => 8.2.12

System => Linux ec9e56c3263d 6.2.0-36-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct  4 10:14:28 UTC 2023 x86_64
Build Date => Oct 28 2023 01:59:11
Build System => Linux 414858d57bde 5.10.0-13-cloud-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux
Configure Command =>  './configure'  '--build=x86_64-linux-gnu' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--with-pic' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr' '--with-curl' '--with-iconv' '--with-openssl' '--with-readline' '--with-zlib' '--disable-phpdbg' '--with-pear' '--with-libdir=lib/x86_64-linux-gnu' '--disable-cgi' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64-linux-gnu'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => (none)
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/31-disable-php-header.ini,
/usr/local/etc/php/conf.d/docker-fpm.ini,
/usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
/usr/local/etc/php/conf.d/docker-php-ext-grpc.ini,
/usr/local/etc/php/conf.d/docker-php-ext-intl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini,
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-redis.ini,
/usr/local/etc/php/conf.d/docker-php-ext-soap.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini

PHP API => 20220829
PHP Extension => 20220829
Zend Extension => 420220829
Zend Extension Build => API420220829,NTS
PHP Extension Build => API20220829,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
Zend Max Execution Timers => disabled
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.2.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.12, Copyright (c), by Zend Technologies
================= PHP EXTENSION INFORMATION
The PHP Extension grpc is installed: 1.59.1
The PHP Extension protobuf is not installed

Description of the bug:

Using the example provided here in the Remarketing/AddFlexibleRuleUserList example.

image

Steps to reproduce:

image

Attempting to update the membership lifespan via the API will result in no change in Google Ads.

Expected behavior: The Audience Manager should reflect the 365 day lifespan I'm sending, not 540.

Request/Response Logs: Here's the debug logs from my attempt to create a user list with the example

[2023-11-08T17:41:41.698198+00:00] google-ads.INFO: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v15.services.UserListService/MutateUserLists", CustomerId: 8995252199, RequestId: "TtqHYeQB4hP39_X1qFpKvQ", IsFault: 0, FaultMessage: "None"  
[2023-11-08T17:41:41.699099+00:00] google-ads.DEBUG: Request
-------
Method Name: /google.ads.googleads.v15.services.UserListService/MutateUserLists
Host: googleads.googleapis.com
Headers: {
    "x-goog-api-client": "gl-php\/8.2.12 gccl\/21.1.0 gapic\/21.1.0 gax\/1.25.0 grpc\/1.59.1 rest\/1.25.0 pb\/+n",
    "User-Agent": "gcloud-php-new\/21.1.0",
    "x-goog-request-params": "customer_id=8995252199",
    "developer-token": "REDACTED",
    "login-customer-id": "6281286582"
}
Request: 
{"customerId":"8995252199","operations":[{"create":{"name":"All visitors to http:\/\/example.com\/example1 AND http:\/\/example.com\/example2 but NOT http:\/\/example.com\/example3 #2023-11-08T17:41:40.937+00:00","description":"Visitors of both http:\/\/example.com\/example1 AND http:\/\/example.com\/example2 but NOT http:\/\/example.com\/example3","membershipStatus":"OPEN","membershipLifeSpan":"365","ruleBasedUserList":{"prepopulationStatus":"REQUESTED","flexibleRuleUserList":{"inclusiveRuleOperator":"AND","inclusiveOperands":[{"rule":{"ruleItemGroups":[{"ruleItems":[{"name":"url__","stringRuleItem":{"operator":"EQUALS","value":"http:\/\/example.com\/example1"}}]}]},"lookbackWindowDays":"7"},{"rule":{"ruleItemGroups":[{"ruleItems":[{"name":"url__","stringRuleItem":{"operator":"EQUALS","value":"http:\/\/example.com\/example2"}}]}]},"lookbackWindowDays":"7"}],"exclusiveOperands":[{"rule":{"ruleItemGroups":[{"ruleItems":[{"name":"url__","stringRuleItem":{"operator":"EQUALS","value":"http:\/\/example.com\/example3"}}]}]}}]}}}}]}

Response
-------
Headers: {
    "content-disposition": "attachment",
    "request-id": "TtqHYeQB4hP39_X1qFpKvQ",
    "date": "Wed, 08 Nov 2023 17:41:41 GMT",
    "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"
}
Response: 
{"results":[{"resourceName":"customers\/8995252199\/userLists\/8483840056"}]}  

Anything else we should know about your project / environment: The only modification I made to the example was to add a needed withLoginCustomerId call to the client used so I could create the list.

This behavior seems most unexpected, according to the API docs when left out, the membership lifespan should default to 30 days; but when I remove the lifespan field it is still getting set to 540 in the Google Ads UI.

fiboknacky commented 11 months ago

Hello,

I'm sorry for the late reply. Your log shows nothing wrong on membershipLifeSpan, so either this is a bug or a known undocumented behavior. Since it's more related on the Google Ads API than this client library, could you please ask on the Google Ads API forum?

Thank you. Knack

austinkregel commented 10 months ago

@fiboknacky I have posted on the Google Ads API forum here, but I have not received a response.

Is there something I can do to try to get a response from the Google Ads team, or to help them figure out what could be wrong?

fiboknacky commented 10 months ago

Hello,

I'm so sorry for this bad experience! While I'm checking why your case isn't responded to, I found that you're not the only person who experienced this membership_life_span issue. It seems other library users also encountered this, so it should be the issue on the API server.

Once I have someone respond to you on the Google Ads API forum, I'll close this issue. Let's keep this open for now.

austinkregel commented 10 months ago

Thank you so much πŸ™‡πŸ»

fiboknacky commented 9 months ago

It looks like this is an intended behavior, but never properly documented. Sorry for this inconvenience. I'll use #980 to track the update of the code example.

austinkregel commented 9 months ago

@fiboknacky I'm not sure I understand, this feature use to work, but now it's apparently not correct.

Was there a change behind the scenes that weren't published? Why is this value ignored for the list now when it wasn't previously?

And like I mentioned, the UI does support editing the value. Would it be possible for the API to have support added for this?

fiboknacky commented 9 months ago

The field is supposed to be set for other types of user list than FlexibleUserList. Do you use this type of user list or other types?

austinkregel commented 9 months ago

We use this type of user list.

We've been using it for years to maintain audiences window of the last 90 days for hundreds of websites.

fiboknacky commented 9 months ago

From what I checked in the codebase, FlexibleUserList was added in Summer 2022 and the behavior was set to be like this since its release. So, you still can set this to 90 days in the UI, right?

austinkregel commented 9 months ago

Yes, I can still set the value to 90 days via the UI.

austinkregel commented 9 months ago

@fiboknacky My codebase in this area hasn't really changed since 2020 to create our users lists.

In order to ensure I wasn't reporting a bug in my code, I verified before creating this issue that the same issue happens with FlexibleUserLists just the same.

image

fiboknacky commented 9 months ago

Thanks for more information. I'll sync with the team to see what is happening. There might be some changes in the pipeline that just surfaced this behavior recently (even though it was programmed to be like that a long time ago). By the way, from your code, it looks like you still create a non-flexible user list?

austinkregel commented 9 months ago

You're welcome! And thank you so much!

We are presently creating a rule based list. The only purpose of the list is to contain visitors to our website in the last 90 days. My team hasn't yet had the bandwidth to upgrade to use a flexible list yet.

I was going to upgrade to use a FlexibleUserList while I work on fixing the membership_life_span, but that's when I discovered this issue πŸ˜…

fiboknacky commented 9 months ago

I see. Thanks for the context and sorry for this inconvenience. That said, I'll keep you posted in this thread.

fiboknacky commented 9 months ago

@austinkregel I'd recommend reading the explanation by my colleague too.

austinkregel commented 9 months ago

@fiboknacky I'll need to speak with my colleagues on our Digital Advertising team to help determine if this could be an acquitted solution for our clients.

I hope to have an answer by the end of the week next week, if it'll work, I'll leave a note and close the issue. Otherwise, I'll update this thread when I have a more concrete answer πŸ‘€

austinkregel commented 9 months ago

@fiboknacky I'm having a little difficulty seeing where my issue overlaps with what your colleague is mentioning.

We want to track any visit to our website in the last 90 days. Exclusive logic won't explicitly facilitate that from my understanding. The screenshots I originally provided were representations of the bug in action, not the desired outcome.

This is the desired user list I'm trying to create via the API, but am unable to. Frame 1 (5)

austinkregel commented 9 months ago

I've gone through and refactored the code I'm working with and it looks like it was upgraded from the old API incorrectly πŸ˜…

I've revised how our app is creating these lists and I've confirmed I can create the needed website inclusion rules. I can confirm that membership_life_span is not needed to create the needed rules βœ… image

Instead of trying to create a UserList with a membership_life_span, I've updated our FlexibleRuleOperandInfo that sets the page url, to also have a lookback_window_days of 90.

image

As far as I'm concerned, this issue can be closed in favor of the other ticket πŸ˜„ thank you very much for all your assistance with this issue πŸ™‡πŸ»

fiboknacky commented 9 months ago

Hey, sorry that I missed your last message. I'm glad that you could resolve this now. And yes, what I meant in the previous reply was that you should use lookback_window_days to do what you want.