Cost per thousand (CPM) is an advertising indicator that represents the cost of one thousand ad impressions. An impression is basically the display of the advertisement by a potential customer. CPM is calculated by taking the cost of an ad, dividing it by the number of real impressions and finally multiplying it by 1000 (CPM = Cost / Impressions x 1000). Most of the time, this value is indicated by the platform providing the ad space and is used to calculate the total cost of an advertising campaign.
Steps
Method 1 of 2: Calculate the CPM
Step 1. Determine the budget available for the advertising campaign
Typically, a marketing action is planned to present an idea or product to the public; if you decide to invest 10,000 euros in advertising, you have half the data you need to calculate the CPM.
Step 2. Determine the total number of impressions
In order to calculate the cost of a thousand of them, you need to know how many you want to publish (you quantify the audience that is reached by the ad).
 For example, the company wants to plan a campaign with 500,000 impressions.
 IT tools such as Google Analytics are useful for determining the traffic of a website; television and the press typically use sales or audience statistics for this data.
Step 3. Do the calculations
The cost of the campaign must be divided by the number of impressions and multiplied by 1000; consequently (10,000 / 500,000) x 1000 = 20.
The company would spend € 20 for 1000 impressions for its advertising campaign which has a budget of € 10,000
Method 2 of 2: Leveraging the Concept
Step 1. Calculate the potential cost of an ad campaign
CPM is often set by the platform that sells the ad space; however, you can use the formula to understand what is the cost you have to incur for a certain number of views.
 Total Cost = (Total Impressions x CPM) / 1000.
 For example, for 1,000,000 views with a CPM of 50 (i.e. $ 50 per 1000 impressions) the company would spend $ 50,000.
Step 2. Calculate the potential audience you can reach within your budget
By leveraging the formulas in the same way, if you have established ad campaign funds and CPM, you can know how many people will potentially see your ad.
 Potential Audience = (Total Cost x 1000) / CPM.
 For example, a budget of $ 50,000 for a campaign with a CPM of 10 achieves 5,000,000 impressions.
Step 3. Sell the space
If you have a website and want to make money from advertising, CPM is calculated based on page traffic and the amount of money the advertiser is willing to spend to reach your audience.
When it comes to online advertising this calculation is often performed automatically using services such as Google Analytics; the value of your space is calculated and sold to those who bet on it
Step 4. Maximize the cost / benefit ratio
CPM rates are useful for companies and advertisers to present their products to a wider audience at a more reasonable cost. This is a very variable indicator that can be used to compare the costs of the spaces of different platforms.
Of course, there are other factors  such as demographic information and ad visibility  that affect the overall effectiveness of an advertising campaign; CPM is a good indicator for a cost analysis
Advice

There are many online calculators that you can use in case you don't want to do the calculations yourself:
 https://www.danielpinero.com/comecalcolarecpm.
 https://www.calculatestuff.com/business/cpmcalculator.
 CPM values may vary based on the price of certain keywords. Most of the companies that do the job of intermediaries for advertisements and that use an auction system allow users to place bets on keywords; the greater the competition, the greater the price of such terms.
 There is a big difference between the PPI and the cost per view (vCPM). The first refers to when an advertisement is requested, shown and is within the user's view. This method does not take into account the fact that the user leaves the page before the ad is fully loaded or that they have installed an adblocking program on their browser. Whenever possible, the advertising company should choose cost per view, as it is a more accurate method of determining the effectiveness and performance of an advertising campaign.
 Remember not to confuse CPM with RPM; the latter is the indicator of "revenue per thousand impressions" and is generally provided to advertisers and creatives who create the content. Represents the estimated revenue per thousand impressions.