Simple SEO forecasting - using position, search volume and anticipated CTR

by Charlie Jackson


Posted on July 2nd, 2021 at 12:00 PM


weighted average rank in pandas

Blog post coming soon.

ctr_dct = {
    1 : 0.18000,
    2 : 0.09000,
    3 : 0.07600,
    4 : 0.06000,
    5 : 0.05500,
    6 : 0.05000,
    7 : 0.03000,
    8 : 0.02250,
    9 : 0.01500,
    10 : 0.01000,
    11 : 0.00850,
    12 : 0.00800,
    13 : 0.00750,
    14 : 0.00700,
    15 : 0.00650,
    16 : 0.00600,
    17 : 0.00550,
    18 : 0.00500,
    19 : 0.0050,
    20 : 0.00450,
    21 : 0.00385,
    22 : 0.00370,
    23 : 0.00355,
    24 : 0.0030,
    25 : 0.00325,
    26 : 0.00310,
    27 : 0.00295,
    28 : 0.00280,
    29 : 0.00265,
    30 : 0.00200,
    31 : 0.00190,
    32 : 0.00180,
    33 : 0.00170,
    34 : 0.00160,
    35 : 0.00150,
    36 : 0.0010,
    37 : 0.00130,
    38 : 0.00120,
    39 : 0.00110,
    40 : 0.00100,
    41 : 0.00090,
    42 : 0.00080,
    43 : 0.00070,
    44 : 0.00060,
    45 : 0.00050,
    46 : 0.00040,
    47 : 0.00030,
    48 : 0.00020, 
    49 : 0.00010,
    50 : 0.00000
}

def forecast(sv, position):
    try:
        sv       = int(sv)
        position = int(position)
        if position >= 50:
            traffic = sv * ctr_dct[50]
            return traffic
        elif position >= 49:
            traffic = sv * ctr_dct[49]
            return traffic
        elif position >= 48:
            traffic = sv * ctr_dct[48]
            return traffic
        elif position >= 47:
            traffic = sv * ctr_dct[47]
            return traffic
        elif position >= 46:
            traffic = sv * ctr_dct[46]
            return traffic
        elif position >= 45:
            traffic = sv * ctr_dct[45]
            return traffic
        elif position >= 44:
            traffic = sv * ctr_dct[44]
            return traffic
        elif position >= 43:
            traffic = sv * ctr_dct[43]
            return traffic
        elif position >= 42:
            traffic = sv * ctr_dct[42]
            return traffic
        elif position >= 41:
            traffic = sv * ctr_dct[41]
            return traffic
        elif position >= 40:
            traffic = sv * ctr_dct[40]
            return traffic
        elif position >= 39:
            traffic = sv * ctr_dct[39]
            return traffic
        elif position >= 38:
            traffic = sv * ctr_dct[38]
            return traffic
        elif position >= 37:
            traffic = sv * ctr_dct[37]
            return traffic
        elif position >= 36:
            traffic = sv * ctr_dct[36]
            return traffic
        elif position >= 35:
            traffic = sv * ctr_dct[35]
            return traffic
        elif position >= 34:
            traffic = sv * ctr_dct[34]
            return traffic
        elif position >= 33:
            traffic = sv * ctr_dct[33]
            return traffic
        elif position >= 32:
            traffic = sv * ctr_dct[32]
            return traffic
        elif position >= 31:
            traffic = sv * ctr_dct[31]
            return traffic
        elif position >= 30:
            traffic = sv * ctr_dct[30]
            return traffic
        elif position >= 29:
            traffic = sv * ctr_dct[29]
            return traffic
        elif position >= 28:
            traffic = sv * ctr_dct[28]
            return traffic
        elif position >= 27:
            traffic = sv * ctr_dct[27]
            return traffic
        elif position >= 26:
            traffic = sv * ctr_dct[26]
            return traffic
        elif position >= 25:
            traffic = sv * ctr_dct[25]
            return traffic
        elif position >= 24:
            traffic = sv * ctr_dct[24]
            return traffic
        elif position >= 23:
            traffic = sv * ctr_dct[23]
            return traffic
        elif position >= 22:
            traffic = sv * ctr_dct[22]
            return traffic
        elif position >= 21:
            traffic = sv * ctr_dct[21]
            return traffic
        elif position >= 20:
            traffic = sv * ctr_dct[20]
            return traffic
        elif position >= 19:
            traffic = sv * ctr_dct[19]
            return traffic
        elif position >= 18:
            traffic = sv * ctr_dct[18]
            return traffic
        elif position >= 17:
            traffic = sv * ctr_dct[17]
            return traffic
        elif position >= 16:
            traffic = sv * ctr_dct[16]
            return traffic
        elif position >= 15:
            traffic = sv * ctr_dct[15]
            return traffic
        elif position >= 14:
            traffic = sv * ctr_dct[14]
            return traffic
        elif position >= 13:
            traffic = sv * ctr_dct[13]
            return traffic
        elif position >= 12:
            traffic = sv * ctr_dct[12]
            return traffic
        elif position >= 11:
            traffic = sv * ctr_dct[11]
            return traffic
        elif position >= 10:
            traffic = sv * ctr_dct[10]
            return traffic
        elif position >= 9:
            traffic = sv * ctr_dct[9]
            return traffic
        elif position >= 8:
            traffic = sv * ctr_dct[8]
            return traffic
        elif position >= 7:
            traffic = sv * ctr_dct[7]
            return traffic
        elif position >= 6:
            traffic = sv * ctr_dct[6]
            return traffic
        elif position >= 5:
            traffic = sv * ctr_dct[5]
            return traffic
        elif position >= 4:
            traffic = sv * ctr_dct[4]
            return traffic
        elif position >= 3:
            traffic = sv * ctr_dct[3]
            return traffic
        elif position >= 2:
            traffic = sv * ctr_dct[2]
            return traffic
        elif position >= 1:
            traffic = sv * ctr_dct[1]
            return traffic
        elif position < 1:
            traffic = sv * ctr_dct[1]
            return traffic
    except Exception as e:
        print(f'Failed: {e}')
        quit()