You need to state the name (and full version number if SugarCube) of the story format you are using, as answers can vary based on this information. I will assume that you are using one of of the Twine 1.x built-in vanilla story formats like Sugarcane.
warning: If you are using one of the vanilla story formats then I strongly suggest you change to SugarCube 2 (or at least SugarCube 1) because modern web-browsers have changed since the vanilla story formats were last maintained and those story formats aren't 100% compatible with all modern web-browsers.
I haven't used Stream's Greenworks API before but the code example you included with your question is Javascript code, not TwineScript and that code consists of two parts:
1. Code to initialise the Greeworks Javascript API.
I would suggest that code like that should be executed within your story's main script tagged special Passage, as you generally only want to initialise an API once and not each time you want to use that API.
2. Code to activate a particular achievement.
This code would most likely need to be directly or indirectly called from within a Passage, how you do that depends on your story format and could be either:
a. A valid script element if using a vanilla story format.
b. A <<script>> macro if using SugarCube 2.x (or even 1.x)
As I don't have access to Greenworks I can't give you tested code examples, but maybe someone else will be able to do that.