Problem/Motivation

When we tried to enter our publisher id (pattern: ca-pub-99999999999) the form validator disallows it. The regex needs updating to include the country code.

Proposed resolution

Change the regex in adsense.admin.inc to the following:

/^([a-z]{2}-){0,1}pub-[0-9]+$/

I'm assuming there may be other country code prefixes to the AdSense publisher ID. I tried to find documentation on it but I didn't find anything.

Comments

jcnventura’s picture

Status: Active » Fixed

Even though the generated output in your ad code starts ca-pub-xxxxxxxxx, if you look at the top right corner of the Google AdSense site, you'll see that your publisher ID starts with pub-xxxxxx.

I'm not Canadian, and my published ID start with ca-pub, so certainly it's not specific to your case.

Anyway, I've updated the module to use the ca-pub-xxxxx in the generated code also, and there's now a check for the correct format when inserting it in the configuration page.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

JoshTango’s picture

Issue summary: View changes

Can you fix this for the Drupal 8. I have the exact same problem today with the ca- prefix.

jcnventura’s picture

Your publisher ID starts with pub-, ca-pub is only in the ad script. Simply type the part starting and including the pub-